[英]Rows selection in GridControl DevExpress
In DevExpress 13 GridControl.TableView with a dynamic list when a row is deleted the row selection doesn't dissapear.在带有动态列表的 DevExpress 13 GridControl.TableView 中,当行被删除时,行选择不会消失。 It remains on the row which replaced the deleted one.
它保留在替换已删除行的行上。 When the selected row is deleted, how can I make the row selection dissapear automatically too?
删除所选行后,如何使行选择也自动消失? I tried to implement it through GridControl.BeginDataUpdate and GridControl.EndDataUpdate., dut it does not work.
我试图通过 GridControl.BeginDataUpdate 和 GridControl.EndDataUpdate. 来实现它,但它不起作用。
private bool _isAlreadyLoaded = false;
private void GridControl_OnLoaded(object sender, RoutedEventArgs e)
{
if (ThisViewModel != null
&& _isAlreadyLoaded == false)
{
ThisViewModel.GettingNewRow += RefreshCommSessionsList;
_isAlreadyLoaded = true;
}
}
//InitializeDataList - method that getting List for GridControl.TableView
public void RefreshCommSessionsList()
{
App.Current.Dispatcher.Invoke(() =>
{
var a = GridControl.GetSelectedRowHandles();
int selectedRowHandle = -1;
if (a.Any())
{
selectedRowHandle = GridControl.View.FocusedRowHandle;
}
GridControl.BeginDataUpdate();
if (NewRowCount < 5 && ThisViewModel != null)
{
ThisViewModel.InitializeDataList();
TableView.DataControl.SelectItem(selectedRowHandle);
}
else
{
GridControl.RefreshData();
TableView.DataControl.SelectItem(selectedRowHandle);
}
GridControl.EndDataUpdate();
NewRowCount++;
});
}
Thank you!谢谢!
You can use GridControl.CurrentItem
property.您可以使用
GridControl.CurrentItem
属性。 If you set its value to null
then the row selection will dissapear.如果将其值设置为
null
则行选择将消失。
GridControl.CurrentItem = null;
To change the FocusedRow of a Grid, use the GridView!要更改网格的 FocusedRow,请使用 GridView!
So if your GridView is named the same as your GridControl it would go as follows,因此,如果您的 GridView 与您的 GridControl 命名相同,它将如下所示,
GridView.FocusedRowChanged(null, null);
//Replace "GridView" with your GridView's name
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.