DataGrid
SelectionUnit CellOrRowHeader
SelectionMode Single
DataGrid.LoadingRow+=(o,ev)=>
{
e.Row.Header = e.Row.GetIndex()+1;
};
protected override void OnSelectedCellsChanged(SelectedCellsChangedEventArgs e)
{
base.OnSelectedCellsChanged(e);
foreach (DataGridCellInfo cl in this.SelectedCells)
{
FrameworkElement ui = cl.Column.GetCellContent(cl.Item);
if (ui is TextBlock tb)
{
Console.WriteLine(tb.Text);
}
}
}
wpf datagrid 获取选择列单元格的值
最新推荐文章于 2024-06-21 11:31:12 发布