如何从 DevExpress GridControl 的选定行单元格中获取变量值

how to get value into variable from selected rows cell from DevExpreess GridControl

我正在使用 DevExpress GridControl,我必须使用 C# 形式将所选行(即一次一行)单元格的值放入变量中。我有一个从 VS2012 内置数据网格控件获取值的代码,但此代码不适用于 DevExpress GridControl,如下所示:

string name=dataGrid1.Rows[dataGridView1.CurrentRow.Index].Cells[2].Value.ToString();
// this is my code for inbuilt VS2012 datagrid control

如何让它适用于 DevExpress GridControl?

我找到了解决方案,我使用 gridView1_FocusedRowChanged() 事件帮助我从 devexpress GridControl 获取价值。代码是:

private void gridView1_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e)
{    
  strEmpNAme= gridView1.GetDataRow(e.FocusedRowHandle)["Emp_Name"].ToString();
  strDOJ= gridView1.GetDataRow(e.FocusedRowHandle)["DOJ"].ToString();
  strDOB= gridView1.GetDataRow(e.FocusedRowHandle)["DOB"].ToString();
}