创建类似于VS二进制文件视图的表单的最佳方法是什么? [英] What is the best way to create a form similar to the VS binary file view?

查看:102
本文介绍了创建类似于VS二进制文件视图的表单的最佳方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不熟悉任何网格控件.

在二进制编辑器中打开文件时,哪个控件最适合创建外观与VS2008视图相同的表单? (地址,十六进制数据字节,ASCII数据字节).我也希望能够编辑数据.

我需要在c#应用程序中显示通过串行端口连接的嵌入式设备的内存内容.

感谢您的任何建议
A

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

推荐答案

这怎么办?

十六进制编辑器(OCX控件) [
What about this?

Hex Editor (OCX Control)[^]


感谢这个建议,正是我所需要的,但我努力将数据传递给控件.

该解决方案需要使用"VariantWrapper".

我创建了一个c#表单测试项目,添加了HexEdit控件和一个按钮,该按钮在click事件中向控件加载了数据.

我需要以下类变量:
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:
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:

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:

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);

}



这使控件正常工作,但我遇到了另一个问题-System.Runtime.InteropServices.SEHException

解决方案在这里:

http://dotnetfreak.co.uk/blog/archive/2004/09/02/system-runtime-interopservices-sehexception.aspx



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


这篇关于创建类似于VS二进制文件视图的表单的最佳方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆