gpt4 book ai didi

c# - 向 Datagrid 添加新行时如何关注特定单元格?

转载 作者:行者123 更新时间:2023-11-30 20:08:47 44 4
gpt4 key购买 nike

当使用 Silverlight/WPF Datagrid 并向现有集合添加新行时,我如何才能跳转到特定单元格的编辑模式以提示用户需要立即填写此字段?

非常感谢,

最佳答案

这就是我如何让它在 SL 5 RC 中工作的。

dg.ItemsSource.Add(data);
dg.SelectedItem = data; //set SelectedItem to the new object
dg.ScrollIntoView(data, dg.Columns[0]); //scroll row into view, for long lists, setting it to start with the first column
dg.Focus(); //required in my case because contextmenu click was not setting focus back to datagrid
dg.BeginEdit(); //this starts the edit, this works because we set SelectedItem above

希望这对您有所帮助。

关于c# - 向 Datagrid 添加新行时如何关注特定单元格?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6720137/

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