GC: Click in frozen column to select the whole row

Hi

In my grid I would like users to be able to click in any frozen column to select the whole row. I have cols.headcount = -1 as I don't want any row headers. ListBoxSelectionMode is set to None as I would like to retain normal per-cell/cell range selection in the rest of the grid.
I have used the following code yet this only works ok for single row selections - I would like to retain CTRL and SHIFT-selection for rows.
Private Sub GridControl1_CellClick(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Grid.GridCellClickEventArgs) Handles GridControl1.CellClick

Dim grid As GridControl = CType(sender, GridControl)

'clicking in any of the frozen columns should select the whole row
If e.ColIndex > 0 And e.ColIndex < grid.Cols.FrozenCount Then
e.Cancel = True
grid.Model.Selections.Add(GridRangeInfo.Row(e.RowIndex))
End If

End Sub

What do I need to change here?

thanks

Richard

3 Replies

HA haneefm Syncfusion Team June 19, 2007 04:02 PM UTC

Hi Richard,

You can try these code snippet.

Private Sub GridControl1_CellClick(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Grid.GridCellClickEventArgs) Handles GridControl1.CellClick
'clicking in any of the frozen columns should select the whole row
If e.ColIndex > 0 And e.ColIndex < GridControl1.Cols.FrozenCount Then
e.Cancel = True
If Control.ModifierKeys() = Keys.Control Then
GridControl1.Model.Selections.Add(oldSelection);
If GridControl1.Model.SelectedRanges.AnyRangeIntersects(GridRangeInfo.Row(e.RowIndex)) Then
GridControl1.Model.Selections.Remove(GridRangeInfo.Row(e.RowIndex))
Else
GridControl1.Model.Selections.Add(GridRangeInfo.Row(e.RowIndex))
End If
ElseIf Control.ModifierKeys() = Keys.Shift Then
GridControl1.Model.Selections.Add(GridRangeInfo.Rows(GridControl1.CurrentCell.MoveFromRowIndex(), e.RowIndex))
Else
GridControl1.Model.Selections.Add(GridRangeInfo.Row(e.RowIndex))
End If
End If
End Sub

Best regards,
Haneef


RB Richard Bysouth June 20, 2007 12:04 AM UTC

Haneef

What is the variable "oldSelection" in that code snippet? Not sure where this should be defined or where its value is set.

thanks

Richard


HA haneefm Syncfusion Team June 20, 2007 09:14 PM UTC

Hi Richard,

Here is a minimal sample that shows you "How to implement the MultiExtend selection behavior in grid when you click on the frozen column?"
GridStyleSample.zip

Best regards,
Haneef

Loader.
Up arrow icon