DataGridView上的按钮未触发 [英] Button Not Firing on DataGridView

查看:80
本文介绍了DataGridView上的按钮未触发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我添加了一个DataGridViewButtonColumn:

I''ve added a DataGridViewButtonColumn :

DataGridViewButtonColumn btnCancel = new DataGridViewButtonColumn();
btnCancel.Name = "btnCanel";
btnCancel.HeaderText = "Cancel";
btnCancel.Text = "CANCEL";
btnCancel.FlatStyle = FlatStyle.Popup;
btnCancel.DefaultCellStyle.ForeColor = Color.Red;
btnCancel.DefaultCellStyle.BackColor = Color.Gainsboro;
btnCancel.UseColumnTextForButtonValue = true;

dataGridView1.Columns.Insert(0, btnCancel);

private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
{
      if (e.ColumnIndex == 0 && e.RowIndex >= 0)
      {
          ulong ordID = (ulong)dataGridView1.Rows[e.RowIndex].Cells[1].Value;
          myFunc(ordID);
      }
}



dataGridView1绑定到bindingList.该bingList全天更新.对象被添加,删除并更新到bindingList.当我单击时,尝试将单元格结果发送到我的方法,但cellClick事件未触发.

有人可以告诉我我在做什么错吗?

预先感谢,
-DA



dataGridView1 is bound to a bindingList. this bingList is updated throughout the day. The objects are being added, removed and updated to the bindingList. When I click I trying to send the the cell results to my method but the cellClick event is not firing.

Can someone please tell me what I''m doing wrong here?

Thanks in advance,
-DA

推荐答案

您是否尝试过使用CellContentClick事件代替CellClick?

.NET 2.0 [ ^ ]说的是一个,但.NET 4.0
Have you tried using the CellContentClick event in place of CellClick?

The documentation is confusing as .NET 2.0 [^] says that''s the one to use but .NET 4.0 [^] says use either.


这篇关于DataGridView上的按钮未触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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