【问题标题】:c# DataGridView getting contents from a Row/Columnc# DataGridView 从行/列获取内容
【发布时间】:2012-04-25 22:38:44
【问题描述】:

我有一个 4 列的 DataGridView。

当用户双击该行时,我想从单击的行的第一列检索数据。

    private void ticketsDataGridView_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
    {
        MessageBox.Show("Row " + e.RowIndex); // gets me the row selected

    }

如何获取所选行的列?

【问题讨论】:

    标签: c# datagrid datagridview datatable


    【解决方案1】:

    DataGridView.Rows Property

    在双击事件上试试这个。

    DataGridViewRow row =dataGridView.Rows[0];
    
    string someStringColumnValue = (string)row.Cells[0].Value;
    

    参考:C# - Lambda syntax for looping over DataGridView.Rows

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-05-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-12-05
      相关资源
      最近更新 更多