Hi
i build a user control that include a GridView and more objects.
i need to display the grid to the user without selecting the first row.
in the DataBindingComplete Event i add this line to unselect row :
this.CurrentRow = null;
when the grid show in the first time it's ok, none of the rows selected.
but when i change the DataSource of the grid, the first row selected !
when i use the debuger i saw that after the DataBindingComplete event run the
SelectionChanged event run too.
when i use the debugger in the first time that the form show, I saw that DataBindingComplete event run and after that the SelectionChanged run and after that DataBindingComplete event run again.
And because of that the line that I add (this.CurrentRow = null;) run in the end and none of the row selected.
What can I do to unselect row ?
I whant that the code I write will be in the user control and not in the forms code.
7 Answers, 1 is accepted

You could just call the ClearSelection() and CurrentRow = null after changing the data source, the DataBindingComplete event fires only once from what I've seen in my tests.
And if you are already using a custom control, create a property inside your control named DataSource that will handle the selection clearing after binding.
Best regards,
Emanuel Varga

are there is event that fire after DataBindingComplete ?
or the last one that fire on gridview ?

There is no other data binding related event after data binding complete, but why are you hesitating to call ClearSelection() and CurrentRow = null after setting a new data source?


public
object
DataSource
{
get
{
return
radGridView1.DataSource;
}
set
{
radGridView1.DataSource = value;
radGridView1.ClearSelection();
radGridView1.CurrentRow =
null
;
}
}
or if you need a data source for more than this create a custom data source property just for the grid.
P.s. I'm assuming you've inherited from RadControl
Let me know if there is anything else i can do to help

Actually there is not a suitable event, which could be used to clear the selection and the current row after the data source has changed. However, your requirement sounds reasonable and we will consider to include a convenient way to do that in the future releases. For the time being you can use the tips, which Emanuel gives you.
I have updated your Telerik points for bringing our attention on this. Let me know if you have any additional questions.
All the best,
Martin Vasilev
the Telerik team