We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

GC: Click in frozen column to select the whole row

Thread ID:

Created:

Updated:

Platform:

Replies:

62594 Jun 19,2007 02:05 AM UTC Jun 20,2007 09:14 PM UTC WinForms 3
loading
Tags: GridControl
Richard Bysouth
Asked On June 19, 2007 02:05 AM UTC

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

haneefm [Syncfusion]
Replied On 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

Richard Bysouth
Replied On 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

haneefm [Syncfusion]
Replied On 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

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;