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: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Row Selections & context menu

Thread ID:

Created:

Updated:

Platform:

Replies:

3904 Apr 17,2003 02:35 AM UTC Apr 17,2003 12:18 PM UTC WinForms 4
loading
Tags: GridControl
Jens Schlegel
Asked On April 17, 2003 02:35 AM UTC

Hi folks, I've got some tiny little problems... Due to postings in this forum I was able to fix some of that, but some probs still remain. The most urgently goes like this: I've got an databound Grid, completely formatted, only complete rows can be selected, multiple selection is possible. We've got a ToolBar-Control from another vendor which we use in all our apps; I've create some contextmenu and bound it to the grid. It works fine. When I select more than one row and rightclick the grid to bring up the contextmenu, allrows but the one I've clicked on are deselected. Can you give me a hint how to keep the whole selection? Thanks in advance, Jens Schlegel@orgatex.net

Administrator [Syncfusion]
Replied On April 17, 2003 09:05 AM UTC

Try handling the grid.Model.SelectionsChanging event and cancel it if the right button is down.
//hook the handler
this.gridDataBoundGrid1.Model.SelectionChanging += new GridSelectionChangingEventHandler(grid_SelectionsChanging);


private void grid_SelectionsChanging(object sender, GridSelectionChangingEventArgs e)
{
	if(Control.MouseButtons == MouseButtons.Right)
		e.Cancel = true;
}

Jens Schlegel
Replied On April 17, 2003 09:19 AM UTC

Sorry, that didn't the trick... I use the following code: Private Sub grdMailOverViewSyncFusion_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles grdMailOverViewSyncFusion.Resize SetGridSizes() End Sub Private Sub grdMailOverViewSyncFusion_CurrentCellActivating(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Grid.GridCurrentCellActivatingEventArgs) Handles grdMailOverViewSyncFusion.CurrentCellActivating e.ColIndex = 0 End Sub Private Sub grdMailOverViewSyncFusion_CurrentCellMoving(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Grid.GridCurrentCellMovingEventArgs) Handles grdMailOverViewSyncFusion.CurrentCellMoving Dim Range As Syncfusion.Windows.Forms.Grid.GridRangeInfo Range = Syncfusion.Windows.Forms.Grid.GridRangeInfo.Cells(e.RowIndex, 1, e.RowIndex, 1) DisplayMail(CStr(grdMailOverViewSyncFusion.DataBoundGridModel.GetCellsInfo(Range)(0).Text)) e.ColIndex = 0 End Sub Private Sub InitializeGrid() AddHandler grdMailOverViewSyncFusion.Model.SelectionChanging, AddressOf SelectionChanging AddHandler grdMailOverViewSyncFusion.DataBoundGridModel.QueryCellInfo, AddressOf QueryCellInfo With grdMailOverViewSyncFusion .Refresh() .AllowSelection = Syncfusion.Windows.Forms.Grid.GridSelectionFlags.Row Or Syncfusion.Windows.Forms.Grid.GridSelectionFlags.Shift Or Syncfusion.Windows.Forms.Grid.GridSelectionFlags.Multiple .HScrollBehavior = Syncfusion.Windows.Forms.Grid.GridScrollbarMode.Disabled .ResizeRowsBehavior = Syncfusion.Windows.Forms.Grid.GridResizeCellsBehavior.None .ResizeColsBehavior = Syncfusion.Windows.Forms.Grid.GridResizeCellsBehavior.ResizeSingle .ListBoxSelectionMode = Windows.Forms.SelectionMode.MultiExtended .TableStyle.Borders.Bottom = New Syncfusion.Windows.Forms.Grid.GridBorder(Syncfusion.Windows.Forms.Grid.GridBorderStyle.None) .TableStyle.Borders.Top = New Syncfusion.Windows.Forms.Grid.GridBorder(Syncfusion.Windows.Forms.Grid.GridBorderStyle.None) .TableStyle.Borders.Left = New Syncfusion.Windows.Forms.Grid.GridBorder(Syncfusion.Windows.Forms.Grid.GridBorderStyle.None) .TableStyle.Borders.Right = New Syncfusion.Windows.Forms.Grid.GridBorder(Syncfusion.Windows.Forms.Grid.GridBorderStyle.None) End With End Sub Private Sub QueryCellInfo(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Grid.GridQueryCellInfoEventArgs) On Error Resume Next If e.RowIndex > 0 AndAlso e.ColIndex > 0 Then If e.RowIndex Mod 2 = 0 Then e.Style.BackColor = System.Drawing.Color.Silver e.Handled = True End If If e.ColIndex = 3 Then e.Style.CellType = "System.Drawing.Image" If CBool(e.Style.CellValue) = True Then e.Style.Font.Bold = True e.Style.ImageList = imlGrid e.Style.ImageIndex = 1 Else e.Style.Font.Bold = False e.Style.ImageList = imlGrid e.Style.ImageIndex = 2 End If e.Handled = True End If If e.ColIndex = 2 Then e.Style.CellType = "System.Drawing.Image" If CBool(e.Style.CellValue) = True Then e.Style.ImageList = imlGrid e.Style.ImageIndex = 0 Else e.Style.CellValue = "" End If e.Handled = True End If End If End Sub Private Sub SelectionChanging(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Grid.GridSelectionChangingEventArgs) If grdMailOverViewSyncFusion.MouseButtons = Windows.Forms.MouseButtons.Right Then e.Cancel = True End If End Sub is there any other way to keep the selection if right mousebutton is clicked? Thanks, Jens js@posthann.de > Try handling the grid.Model.SelectionsChanging event and cancel it if the right button is down. > ...

Administrator [Syncfusion]
Replied On April 17, 2003 12:15 PM UTC

The Control.MousePosition is a Shared (static in C#) property. So instead of grdMailOverViewSyncFusion.MouseButtons = Windows.Forms.MouseButtons.Right use Control.MouseButtons = Windows.Forms.MouseButtons.Right

Administrator [Syncfusion]
Replied On April 17, 2003 12:18 PM UTC

Oops. Meant to say Control.MouseButtons is a static property (though Control.MousePosition is also a static property but that comment is off topic).

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

;