How to use C# to display Registry results on Rich Text Box? -


i have program able retrieve various registry values using c# codes compiled , created using vs 2010.

however problem arises when tried display results retrieved windows registry rich text box within form.

the form shows 1 line last value in array contains results.

please give advice on codes. thanks!

using system; using system.collections.generic; using system.componentmodel; using system.data; using system.drawing; using system.linq; using system.text; using system.windows.forms; using microsoft.win32;  namespace syscrawl { public partial class ftk_menu_browsing_history : form {     public ftk_menu_browsing_history()     {         initializecomponent();     }      private void buttonfilehistory_click(object sender, eventargs e)     {         this.hide();         ftk_menu_file_history mfh = new ftk_menu_file_history();         mfh.showdialog();         this.close();     }      private void buttonencryptedfiles_click(object sender, eventargs e)     {         this.hide();         ftk_menu_encrypted_files mef = new ftk_menu_encrypted_files();         mef.showdialog();         this.close();     }      private void buttonrecentlyaccessedfiles_click(object sender, eventargs e)     {         this.hide();         ftk_menu_recently_accessed_files mraf = new ftk_menu_recently_accessed_files();         mraf.showdialog();         this.close();     }      private void buttonregistryhistory_click(object sender, eventargs e)     {         this.hide();         ftk_menu_registry_history mrh = new ftk_menu_registry_history();         mrh.showdialog();         this.close();     }      private void buttonmainmenu_click(object sender, eventargs e)     {         this.hide();         menu m = new menu();         m.showdialog();         this.close();     }      private void buttonlogout_click(object sender, eventargs e)     {         this.hide();         syscrawl_login sl = new syscrawl_login();         sl.showdialog();         this.close();     }      private void ftk_menu_browsing_history_load(object sender, eventargs e)     {         try         {             registrykey rk = registry.currentuser;              rk = rk.opensubkey("software\\microsoft\\internet explorer\\typedurls",      false);             printkeys(rk);             rk.close();         }         catch (exception myerror)         {             richtextboxbrowsing.text="an error has occurred: " + myerror.message;         }     }      void printkeys(registrykey rk)     {         if (rk == null)         {             richtextboxbrowsing.text="couldn't open desired subkey.";             return;         }          richtextboxbrowsing.text = "subkeys of " + rk.name;          try         {             string[] valnames = rk.getvaluenames();             int = 0;              foreach (string s in valnames)             {                 string val = (string)rk.getvalue(valnames[i++]);          richtextboxbrowsing.text="-----------------------------------------------";                 richtextboxbrowsing.text=s + " contains " + val;             }         }          catch (exception myerror)         {             richtextboxbrowsing.text = "an errors has occurred: " + myerror.message;         }     }      private void richtextboxbrowsing_textchanged(object sender, eventargs e)     {      }    }  } 

by saying:

richtextboxbrowsing.text= 

in each iteration of loop, keep on overwriting text. last call text property gets printed.

you need set richtextboxbrowsing.textmode property multiline, , instead call:

richtextboxbrowsing.appendtext(s + " contains " + val + "\n"); 

oh, , way, use: string val = rk.getvalue(s).tostring();

so can remove int = 0; declaration


Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

html - Instapaper-like algorithm -

c# - How to execute a particular part of code asynchronously in a class -