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

Selecting only cells of one row

1 Answer 28 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Peter
Top achievements
Rank 1
Peter asked on 06 Nov 2013, 08:18 AM
Hi, 

I have a GridView with 

grid.MultiSelect = true;
grid.SelectionMode = GridViewSelectionMode.CellSelect;

How can I achieve a behavior where the user can only multiselect cells of one row? I tried to use the gridFehlzeitenuebersicht_SelectionChanging Event without success. I think I just need a nice hint in the right direction. Thank you in Advance. 

I'm using C# and RadControls for WinForms V. 2013.3.1016.40. 

Best, 

Peter 

1 Answer, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 08 Nov 2013, 09:13 AM
Hello Peter,

Thank you for writing.

The SelectionChanging event seems like the right place do achieve the desired scenario. There you can access the already selected cells (via the SelectedCells collection of RadGridView) and the cell which attempts to be selected (vie the CurrentCell property of RadGridView). Here is a small sample:
void radGridView1_SelectionChanging(object sender, CancelEventArgs e)
{
    if (radGridView1.SelectedCells.Count > 0)
    {
        if (radGridView1.SelectedCells[0].RowInfo != radGridView1.CurrentRow)
        {
            e.Cancel = true;
        }
    }
     
}

I hope this helps.

Regards,
Stefan
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
GridView
Asked by
Peter
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Share this question
or