English 中文(简体)
视觉C#——与单元DoubleClick活动的联系活动手稿
原标题:Visual C# - Associate event handler with CellDoubleClick event

Im在视觉演播室工作,试图从一个数据GridView室获取信息,用户在两处点击。 我基本上像任何其他浮雕事件一样,设立了小组会议,但似乎没有工作。

法典:

表格1.c

private void dataGridView1_CellDoubleClick(Object sender, DataGridViewCellEventArgs e)
    {

        System.Text.StringBuilder messageBoxCS = new System.Text.StringBuilder();
        messageBoxCS.AppendFormat("{0} = {1}", "ColumnIndex", e.ColumnIndex);
        messageBoxCS.AppendLine();
        messageBoxCS.AppendFormat("{0} = {1}", "RowIndex", e.RowIndex);
        messageBoxCS.AppendLine();
        MessageBox.Show(messageBoxCS.ToString(), "CellDoubleClick Event");
    }

表格1中的连续代码。

this.dataGridView1.CellDoubleClick += new System.EventHandler(this.dataGridView1_CellDoubleClick);

我在表1中看到了一个错误。 设计者代码说,“没有超载数据GridView1_CellDoubleClick配对系统。 活动Handler

How can I get the double click to work correctly? Thanks.

最佳回答

The CellDoubleClick event is a DataGridViewCellEventHandler, not an EventHandler`.

You should add the event handles using the designer, which will automatically use the correct delegate type.
You should not edit the designer-generated code manually.

In general, when adding event handlers, you shouldn t explicitly create the delegate.
Instead, you can write

myGrid.CellDoubleClick += MyGrid_CellDoubleClick;
问题回答

暂无回答




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签