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

标签 c# .net wpf silverlight datagrid

当使用 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/

相关文章:

c# - queryCommandValue ("FontSize") 返回什么?

c# - 添加到 Lambda 表达式并使用 Entity Framework

c# - 如何从代码中关闭 NotifyIcon BallonToolTip?

c# - WPF 的自动完成组合框

c# - WPF自定义控件依赖属性: cannot be string type?

wpf - WPF 图像控件中的初始图像

wpf - 每次使用 mvvm、wpf 从 Checkedlistbox 选择项目时了解的事件或命令

c# - 禁用控制+ C关闭程序

C# 改变按钮的背景颜色

c# - 命名空间 "..."中不存在名称 "clr-namespace"