Having a bizarre issue with RadGridView where it seems to randomly be selecting items in the grid when the underlying ObservableCollection is changed. My desired behavior is the "CurrentItem" becoming null when the selected item is removed from the underlying collection, and obviously for the GridView not to select an item when added when the selection is blank. My code is as follows:
radGridView1.AutoExpandGroups = true;
var gd = new GroupDescriptor();
gd.GroupNames.Add("RandomProp1", ListSortDirection.Ascending);
radGridView1.GroupDescriptors.Add(gd);
var sd1 = new SortDescriptor("RandomProp2", ListSortDirection.Descending);
radGridView1.SortDescriptors.Add(sd1);
var sd2 = new SortDescriptor("RandomProp3", ListSortDirection.Ascending);
radGridView1.SortDescriptors.Add(sd2);
radGridView1.MultiSelect = false;
radGridView1.DataBindingComplete += RadGridView1_DataBindingComplete;
radGridView1.DataSource = App.MasterList;
private void RadGridView1_DataBindingComplete(object sender, Telerik.WinControls.UI.GridViewBindingCompleteEventArgs e)
{
Log.WriteLine("RadGridView_DataBindingComplete");
radGridView1.CurrentRow = null;
radGridView1.CurrentRowChanged += RadGridView1_CurrentRowChanged;
}
When the underlying collection is being changed, I'm doing the following:
BeginInvoke on the main thread
Locking the collection
Updating items as such:
DynamicCollection[i] = new CustomObject(fillerProperties);
Is the above possibly the issue? I know this is the correct way to update ObservableCollections in WPF when bound to a GridView, not sure if WinForms behaves differently.