【问题标题】:How to check which cell in dataGridView is selected?如何检查 dataGridView 中的哪个单元格被选中?
【发布时间】:2012-05-15 18:38:19
【问题描述】:

我想从dataGridView中的选定单元格发送多个邮件,但不知道如何找出哪些单元格被选中,所以问题是如何找出哪些单元格被选中?

我可以做一些循环来遍历单元格并测试选择(检查)哪个单元格吗?

语言 c#。

【问题讨论】:

    标签: c# select datagridview


    【解决方案1】:

    使用DataGridView.SelectedCells 属性。

    foreach(DataGridViewCell cell in dataGridView.SelectedCells)
    {
        //do something
    }
    

    【讨论】:

      【解决方案2】:
      DataGridViewSelectedCellCollection selectedCells = myDataGridView.SelectedCells;
      

      查看示例:How to: Get the Selected Cells, Rows, and Columns in the Windows Forms DataGridView Control

      【讨论】:

      • @John,不客气。如果有帮助,请采纳答案。谢谢。
      • 我会,但现在我没有太多要评价的点......但随着时间的推移,我会继续前进
      • @John 在此处查看以了解如何接受答案。你不需要有声望就可以接受它。
      猜你喜欢
      • 2013-04-15
      • 2014-07-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-08-07
      • 2012-09-08
      相关资源
      最近更新 更多