Select cells from only 1 column at a time

2 posts, 0 answers
  1. Misha
    Misha avatar
    12 posts
    Member since:
    Aug 2012

    Posted 07 Nov 2012 Link to this post

    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
  2. Misha
    Misha avatar
    12 posts
    Member since:
    Aug 2012

    Posted 07 Nov 2012 Link to this post

    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!
Back to Top