gpt4 book ai didi

WPF : Get index of clicked/selected cell on DataGrid

转载 作者:行者123 更新时间:2023-12-04 17:01:13 29 4
gpt4 key购买 nike

如何在 DataGrid 上获取单击/选定单元格的索引?

我的 DataGrid 列是自动生成的,我不想使用任何 DataTemplate 。

<DataGrid ItemsSource="{Binding Table, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, IsAsync=True}"
AutoGenerateColumns="True">
</DataGrid>

最佳答案

DataGrid x = (DataGrid)this.FindName("myDataGrid");
var index = x.SelectedIndex;

还有其他有用的属性:
x.CurrentColumn;
x.CurrentItem;
x.SelectedItem;
x.SelectedValue;

关于WPF : Get index of clicked/selected cell on DataGrid,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18616539/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com