4 Answers, 1 is accepted
I'm pretty sure the previous posts are out-dated since there are a number of properties that no longer exist - I'm using the latest version of RadGridView for WinForms
I have a grid that's grouped by column "Type" and further is sorted by "Name"
If I select the 5th row down...then later I mygrid.Rows.Clear and then I reload the grid...the 5th row down is still selected so that's my first question: How do I CLEAR the currentrow? Here's what I have so far:
As you can see I'm throwing everything at the grid except the kitchen sink...the above code IS running prior to me reloading the grid...but when the grid reloads - there I am, right back at the same row as previously selected :(
My next question is why I'm in this thread: How do you select the first row DISPLAYED (regardless of what group it may be in)?
Also - while I do have my grid grouped like this:
If I check myGrid.Groups.Count it will = 0 - Shouldn't the groups collection get automatically filled when the grid loads or is there something more I need to do?
Any assistance/help/guidance would be very appreciated!
This is a very old post and the provided solution is relevant for the version of RadGridView back in 2009. Note that the RadGridView control has been refactored after that. We wanted to keep most of the public API unchanged but indeed some of the properties/methods no longer exist.
Straight to your question:
- You can simply set the CurrentRow property to null after populating with data if you need to clear the selection.
- After you group the grid, the RadGridView.ChildRows collection will contain all groups. Then, if you need to select the first row in the first group, you can simply select the RadGridView.ChildRows.ChildRows. Additional information about the Rows and ChildRows collection is available in the following help article: https://docs.telerik.com/devtools/winforms/gridview/rows/rows-vs-childrows
I hope this information helps. If you have any additional questions, please let me know.
Oh! You folks made it easy as Pie didn't you!? :)
Thanks Dess. That explains a ton and makes life a whole heck of a lot easier.
Have a great day.