WPF DataGrid - Set a cell into edit mode programmatically

后端 未结 2 1740
感情败类
感情败类 2021-02-19 09:50
  • I have a WPF DataGrid that shows some data records (bounded to an ObservableCollection).

  • When the user clicks \"Edit\" button, the currend selected row

相关标签:
2条回答
  • 2021-02-19 10:39

    Here is the documentation of the WPF DataGrid on MSDN. The BeginEdit method seems to be what you are looking for.

    PS: I don't know if this is suitable for your application, but many DataGrid users find Single-Click Editing useful.

    0 讨论(0)
  • 2021-02-19 10:43

    Assuming WPF:

    <DataGrid x:Name="dg".... />
    

    Then this code will work:

    dg.CurrentCell = new DataGridCellInfo(dg.Items[i], dg.Columns[j]);
    dg.BeginEdit();
    
    0 讨论(0)
提交回复
热议问题