How to change Selected cell when occur MouseLeftBttonDown event

Posted by: dovanthuc09 on 17 June 2018, 2:50 pm EST

    • Post Options:
    • Link

    Posted 17 June 2018, 2:50 pm EST

    Hi

    In C1DataGrid,

    I successed in changing selected row after mouse left button DOWN

    but I can NOT change selected CELL after mouse left button DOWN (default is the selected cell will be changed when mouse left button UP)

    This is how I change selected row by MouseLeftButtonDown event

    [i]private void OnC1DataGridRowPreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)

    {

    var rowPresenter = sender as DataGridRowPresenter;

    if (rowPresenter == null || dataGridView.SelectionMode != DataGridSelectionMode.SingleRow) return;

            dataGridView.SelectedIndex = rowPresenter.Row.Index;
        }[/i]
    

    Could you give me a way to solve this problem? Thank you so much!

  • Posted 18 June 2018, 9:57 pm EST

    Hi,

    You could take help of GetCellFromPoint method in PreviewMouseLeftButtonDown event and assign the cell obtained to CurrentCell property, as follows:```

    var cell = _grid.GetCellFromPoint(e.GetPosition(_grid)) as C1.WPF.DataGrid.DataGridCell;

    _grid.CurrentCell = cell;

    Thanks,
    Ruchir
  • Posted 2 July 2018, 1:24 pm EST

    Thank you for supporting

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels