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

Select cells from only 1 column at a time

1 Answer 51 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Misha
Top achievements
Rank 1
Misha asked on 07 Nov 2012, 07:25 PM
Hello, is it possible in Extended - Cell selection mode to only allow the user to select cells from 1 column at a time?

I want to allow the user to to vertically select an X amount of cells, but it can only span 1 column. If they want to select something in another column, they will have to start a new selection. I can make it so a context menu doesn't show up if right clicking when multiple columns are selected (this is ok..), but it would be awesome if I could prevent the user from selecting multiple columns in the first place.

I'd imagine this isn't supported out of box, but if there is an easy way to customize this, that would be great!

I attached an image of the functionality I'm hoping for.

Thank you!
-Misha

1 Answer, 1 is accepted

Sort by
0
Misha
Top achievements
Rank 1
answered on 07 Nov 2012, 07:51 PM
I think I found a solution =]

I attached the SelectedCellsChanging event to this method:

private void grid_SelectedCellsChanging(object sender, GridViewSelectedCellsChangingEventArgs args) {
  RadGridView gridView = (RadGridView)sender;
  if(gridView.SelectedCells.Select(c => c.Column.DisplayIndex).Distinct().Count() > 1) {
    args.Cancel = true;
  }
}

Looks like it works!
Tags
GridView
Asked by
Misha
Top achievements
Rank 1
Answers by
Misha
Top achievements
Rank 1
Share this question
or