This is a migrated thread and some comments may be shown as answers.

Grid always have a selected row

4 Answers 460 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Maher Khalil
Top achievements
Rank 1
Maher Khalil asked on 19 May 2010, 09:44 PM
Hello

version 2009.2.9.701
I'm binding the grid whit a binding source in the designer
when start the form always the first row in the grid is selected
 both the event CurrentRowChanged ,SelectionChanged fire with the form load
how can i make no selected rows in start up and stop both events from firing in the form load

second Q
after selecting a row how do i unselect  (selected rows = 0)

thank you

4 Answers, 1 is accepted

Sort by
0
Accepted
Alexander
Telerik team
answered on 20 May 2010, 05:21 PM
Hello Maher Khalil,

Please, consider the code snippet added to the Form_Load event handling method:

this.radGridView1.CurrentRow = null;
 
this.radGridView1.CurrentRowChanged += new CurrentRowChangedEventHandler(radGridView1_CurrentRowChanged);
this.radGridView1.SelectionChanged += new EventHandler(radGridView1_SelectionChanged);

You can use the above code to remove the RadGridView initially selected row (which is the current row as well). To prevent the initial firing of CurrentRowChanged and SelectionChanged, please, subscribe for them after nullifying the current row (as shown in the code snippet).

Concerning your second question: you can manipulate the RadGridView SelectedRows collection using known from .NET API with Add(), Insert(), Remove(), RemoveAt(), Clear() methods.

Please, review the provided documentation for further help.

A bit off topic, please ask the person who has purchased our controls in your company to add you as a License Developer to the purchase. This will give you full access to the products your company has purchased, to our downloads section, and to our support ticketing system. Additionally, all your questions will be reviewed according to the license you have. More information on License Developers you can find here: www.telerik.com/account/faqs.aspx.

All the best,
Alexander
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Narayan Solanki
Top achievements
Rank 1
answered on 27 May 2010, 02:02 PM
Hi,

Is it possible disable row selection?
If yes then how should i do that?

Thanks,
Narayan
0
Alexander
Telerik team
answered on 28 May 2010, 03:01 PM
Hello Narayan,

You can disable the row selection by cancelling the CurrentRowChanging event:
this.radGridView1.CurrentRow = null;
this.radGridView1.CurrentRowChanging += new CurrentRowChangingEventHandler(radGridView1_CurrentRowChanging);
 
private void radGridView1_CurrentRowChanging(object sender, CurrentRowChangingEventArgs e)
{
    e.Cancel = true;
}

Regards,
Alexander
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Narayan Solanki
Top achievements
Rank 1
answered on 28 May 2010, 03:45 PM
Thanks Alexander,

This did the trick for me :)

Kind Regards,
Narayan
Tags
GridView
Asked by
Maher Khalil
Top achievements
Rank 1
Answers by
Alexander
Telerik team
Narayan Solanki
Top achievements
Rank 1
Share this question
or