【问题标题】:How to use DataGridViewButtonColumn in non bound DataGridView如何在未绑定的 DataGridView 中使用 DataGridViewButtonColumn
【发布时间】:2009-06-23 16:12:39
【问题描述】:

使用 WinForms、C# .Net 2.0

我正在向未绑定的 DataGridView 添加行。我想在单击时删除该行的列之一中有一个 DataGridViewButtonColumn。当我尝试将 Click 事件添加到 DataGridViewButtonColumn 时,似乎没有 Click 的定义。

谁能给我指出一篇 MSDN 文章或指导我找到答案?

谢谢!

【问题讨论】:

    标签: datagridview button


    【解决方案1】:

    DataGridViewButtonColumn 类是 DataGridViewButtonCell 对象的容器类。这些对象具有您正在寻找的点击事件。

    http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridviewbuttoncolumn_members.aspx

    【讨论】:

      【解决方案2】:

      DataGridViewButtonColumn MSDN 页面有这样的说法:

      要响应用户按钮点击,请处理 DataGridView.CellClick 或 DataGridView.CellContentClick 事件。在事件处理程序中,您可以使用 DataGridViewCellEventArgs.ColumnIndex 属性来确定单击是否发生在按钮列中。您可以使用 DataGridViewCellEventArgs.RowIndex 属性来确定单击是否发生在按钮单元格而不是列标题上。

      【讨论】:

      • 如果是列标题,则 RowIndex=-1
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-02-07
      相关资源
      最近更新 更多