Hi,
I´m working with the XamlDataGrid and currently when the Grid is loaded I´m selecting the first element of the Grid, using the following code:
this.gridDataPresenter.SelectedItems.Records.Add(gridDataPresenter.Records[0]);
This code is working fine, but the problem is that later I need to unselect the selected items of the Grid, for later selecting only the first item. For unselecting the record I´m using the following code, that is giving me an exception.
this.gridDataPresenter.SelectedItems.Records.Clear();
As I read on the documentation of the Records attribute, this propery is not accesible on run time. So I will like to know if there is a way to unselect the items on a Grid.
Great news!
Thanks for letting us know you solved the problem!
Hi Curtis,
I solved it!!! The problem was that I was using a previous version of the NetAdvantage Suite, so I updated i, and everything is working fine.
Thanks!!
Thanks for posting your code.
I don't see why you are getting the exception. I suspect there is something going on somewhere else and this is a side effect.
Are you using the latest version of NetAdvantage with Hot Fixes? If not, please see if you can reproduce this problem with the latest releases.
Can you reproduce this problem by separating the snippet you sent me into a smaller sample project?
If you would report this to our developer support team as a bug, that would help us solve this problem. If you request a work-around from DS, that will help you get going. If you can reproduce this in a sample project, that will help us solve the problem faster as well.
http://es.infragistics.com/support/ask-for-help.aspx
Thank you!
Yes I tried and I´m receiving the following Exception:
Specified argument was out of the range of valid values.Parameter name: index
The code that I used is the following:
this.gridDataPresenter.DataSource = value; if (value.Count > 0) { for (int x = 0; x < gridDataPresenter.Records.Count; x++) { if (gridDataPresenter.Records[x].IsSelected) this.gridDataPresenter.Records[x].IsSelected = false; } this.gridDataPresenter.SelectedItems.Records.Add(gridDataPresenter.Records[0]); }
When the Exception is thrown the current x index is 0. So I don´t know why is this happening.
Have you tried using the IsSelected property?
this.gridDataPresenter.Records[0].IsSelected = false;