Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
2589
Multiple cells selection
posted

Hello,

I don't want to allow user to select a non-rectangular area when selecting multiple cells (CTRL+Clicks), allowing him only to select a rectangular area. Is there a workaround for this?

Thank you.

Parents
No Data
Reply
  • 6475
    Verified Answer
    posted

    A possible workaround would be to add event handler for SelectedCellsCollectionChanged event , check if the Ctrl key is pressed, and if this case, restore the previous selection state:

    XAML Code:

    <ig:XamGrid x:Name="igGrid" 

        SelectedCellsCollectionChanged="igGrid_SelectedCellsCollectionChanged">  

    <ig:XamGrid.SelectionSettings>

    <ig:SelectionSettings CellSelection="Multiple" />

    </ig:XamGrid.SelectionSettings>

    </ig:XamGrid>

     

    C# Code:

    private void igGrid_SelectedCellsCollectionChanged(object sender, SelectionCollectionChangedEventArgs<SelectedCellsCollection> e)

    {

    if ((Keyboard.Modifiers & ModifierKeys.Control) > 0)  

    {

    igGrid.SelectedCellsCollectionChanged -= igGrid_SelectedCellsCollectionChanged;    

    igGrid.SelectionSettings.SelectedCells.Clear();    

    igGrid.SelectionSettings.SelectedCells.AddRange(e.PreviouslySelectedItems);

    igGrid.SelectedCellsCollectionChanged += igGrid_SelectedCellsCollectionChanged;   

    }

    }

     

    Hope that helps,

Children