how to set focus to particular cell of WPF toolkit datagrid

后端 未结 5 1343
再見小時候
再見小時候 2020-12-29 08:58

I am using WPF toolkit provided DataGrid control to display product list along with its OpenStock, Description etc. In this DataGrid i have set OpenStock column to editable

5条回答
  •  离开以前
    2020-12-29 09:33

    This worked for me:

    DataGridCellInfo dataGridCellInfo = new DataGridCellInfo(dataGrid1.Items[sampleRowIndex], dataGrid1.Columns[sampleColumnIndex]);
    dataGrid1.SelectedCells.Clear();
    dataGrid1.SelectedCells.Add(dataGridCellInfo);
    

    This will select the cell you want to put the focus on.

    A DataGridCellInfo object provides information about a cell and the data item that is associated with the cell. It is used instead of a reference to the actual DataGridCell object when the DataGrid control gets a cell, for example in the CurrentCell or SelectedCells properties. Check here for more info.

提交回复
热议问题