如何在datagridview devexpress中获取单元格的值

How to get a value of a cell in datagridview devexpress

我有一个 Datagridview,其中第一列包含复选框,第二列包含文本。 单击复选框时,"CellValueChanging" 方法获取特定行的索引。 如何获得匹配的字符串文本?文本的列索引始终相同 (1)

您可以使用GetRow()方法获取行:

var row = TaskGridView.GetRow(1) as YourModel;

使用 ValueChangedEvent:

private void TaskGridView_CellValueChanged(object sender, CellValueChangedEventArgs e)
{
    if (e.RowHandle < 0)
            return;

    var row = TaskGridView.GetRow(e.RowHandle) as YourModel;       
}

对于特定的列,您可以执行以下操作:

 private void TaskGridView_CellValueChanged(object sender, CellValueChangedEventArgs e)
 {
        if (e.RowHandle < 0)
                return;

        var row = TaskGridView.GetRow(e.RowHandle) as YourModel;

       if (e.Column.FieldName.Equals("YourFieldName", StringComparison.InvariantCultureIgnoreCase))
       {
           // do something here
       }       
  }