Click here to Skip to main content
15,922,166 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am not familiar with any of the grid controls.

Which control would be best suited to creating a form that has the same appearance as the VS2008 view when a file is opened in the binary editor? (Address, data bytes in hex, data bytes in ASCII). I want to be able to edit the data as well.

I need this in a c# application to show memory contents of an embedded device conntected via the a serial port.

Thanks for any suggestions
A
Posted

What about this?

Hex Editor (OCX Control)[^]
 
Share this answer
 
Thanks for the suggestion its just what I need but I struggled to pass data to the control.

The solution required the use of a "VariantWrapper".

I created a c# form test project, added the HexEdit control and 1 button that loaded the control with data in the click event.

I needed the following class variables:
C#
public partial class Form1 : Form
{
    // to wrap the array that I am going to pass
    System.Runtime.InteropServices.VariantWrapper var;
    // the actual array that I will pass
    Array t;
    // an object to pass to the SetData method
    object o;
    .
    .


In the form constructor:
C#
public Form1()
{
    InitializeComponent();
    // create an array of 50 bytes to send to the control
    t = Array.CreateInstance( typeof(byte), 50 );



Then in my click event:
C#
private void button1_Click(object sender, EventArgs e)
{
    // load the array with some data
    for (int i = t.GetLowerBound(0); i <= t.GetUpperBound(0); i++)
        t.SetValue((byte)(i + 0x30), i);

    // Create a wrapper 'var' around t
    var = new System.Runtime.InteropServices.VariantWrapper(t);
    // copy var into an object and pass to the control
    o = var;
    axHexEdit1.SetData(ref o, 0);

}


This got the control working but I ran into another problem - System.Runtime.InteropServices.SEHException

The solution for that is here:

http://dotnetfreak.co.uk/blog/archive/2004/09/02/system-runtime-interopservices-sehexception.aspx
 
Share this answer
 
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