C1DataGrid - How to Unselect the selected Row

Posted by: nagarjunpasunoori on 14 July 2019, 6:06 pm EST

    • Post Options:
    • Link

    Posted 14 July 2019, 6:06 pm EST - Updated 3 October 2022, 11:02 pm EST

    Hello!

    I need help to unselect the selected complete row from the C1DataGrid.

    And, If I select multiple rows from grid, that selected rows are updating to grid selectedItems property. But, while trying to unselect the row and trying to remove the selected row from Grid SelectedItems property, we are unable to do that both above operations.

    Please suggest me to how to do it.

    Thanks,

    Nagarjun

  • Posted 15 July 2019, 5:39 pm EST

    Hi Nagarjun,

    This may depend on how and when you are modifying the selection to unselect a row. I tried to unselect a row by clicking on a button as follows:

    private void BtnUnSelect_Click(object sender, RoutedEventArgs e)
    {
     var selection = dataGrid.Selection;
     if (selection.SelectedRows.Count > 0)
      selection.Remove(selection.SelectedRows.First(), selection.SelectedRows.First());
    }
    
    

    and this works fine. So, I would request you to verify the same using the attached sample (prj_UnselectingRow.zip) and let me know if there is need to change something.

    Thanks,

    Basant

    prj_UnselectingRow.zip

  • Posted 15 July 2019, 8:33 pm EST

    Thanks for the reply Basant,

    I need help for Component One DataGrid. For this C1DataGrid, I am not getting Remove event. Then, how can I remove selected row.

  • Posted 16 July 2019, 9:21 pm EST

    Hi Nagarjun,

    I am sorry but I could not understand your concern. Can you please let me know the following:

    1. The version of C1DataGrid that you are using.(I used 4.0.20191.630 for the sample)
    2. How & when do you want to unselect the row?(like From UI [e.g. Ctrl + Click a selected row : supported by default] or from code)

    If possible, I would request you to make changes in the sample that was provided earlier to reproduce your scenario.

    Thanks,

    Basant

  • Posted 16 July 2019, 11:55 pm EST

    Hi Basant,

    Actually, I am using this Grid 4.0.20111.125 version and it is Silverligtht project with VB.net and C1 components grid. Here, I am selecting the row by Clicking “Ctrl + Click”, I want too unselect the row by clicking “Ctrl + Click” only.

    “gridNeedsAssignment.SelectionMode = C1.Silverlight.DataGrid.DataGridSelectionMode.MultiRow” by using this code I am selecting multiple rows. For unselect the row, I am not getting Remove event. Could you please help me.

    Thanks,

    Nagarjun

  • Posted 18 July 2019, 9:47 pm EST

    Hi Nagarjun,

    Thanks for sharing the information. I could observe that the DataGridSelection.Remove() method is not present in version 2011v1. Also,I found that this method was added in version 2012v1. So, alternatively, you can modify the selection to unselect a row as follows:

    'Unselect the top-most row.
    Dim selection = dataGrid.Selection
    
    If selection.SelectedRows.Count > 0 Then
     Dim rows = selection.SelectedRows.ToList()
     selection.Clear()
    
     For i As Integer = 1 To rows.Count() - 1
      selection.Add(rows(i), rows(i))
     Next
    End If
    

    Hope this will help.

    Thanks,

    Basant

Need extra support?

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

Learn More

Forum Channels