Click here to Skip to main content
15,891,253 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
private void btnResize_Click(object sender, EventArgs e)
     {
         Width = 580;
         Height = 487;
       //  string []buffer =new byte[ richTextBox2.Text];

         byte[] buffer = Encoding.Default.GetBytes(richTextBox2.Text);

       //  byte[] buffer = BitConverter.GetBytes(Convert.ToDouble(richTextBox2.Text));

         // From byte array to string

         string bb = "";
         int i = 0;
         ////int numBytesToRead = buffer.Length;
         while (i < richTextBox2.TextLength)
         {
             if ((i % 8) == 0)
             {
                 bb = bb + "\n";
                 bb = bb + i.ToString("X8");
                 bb = bb + "\t";
             }
             else if ((i % 4) == 0)
             {
                 bb = bb + "\t";
             }
             bb = bb + buffer[i].ToString("X2"); // modified on 30june2014

             i = i + 1;
         }
         richTextBox2.Text = bb;

     }

Actually I did the display of hex data in richtexbox2 in following format
00000000 4D696372 6F736F66 74205351 4C205365
00000010 72766572 20416E61 6C797369 73205365

now when I click to the resize button which is on the form the above data should be like following format
00000000 4D696372 6F736F66
00000008 74205351 4C205365
00000010 72766572 20416E61
00000018 6C797369 73205365
Posted
Updated 23-Jul-14 21:17pm
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900