Thread ID: |
Created: |
Updated: |
Platform: |
Replies: |
14643 | Jun 1,2004 04:43 PM UTC | Jun 28,2004 12:02 PM UTC | WinForms | 23 |
![]() |
Tags: GridControl |
Dim c As Control = Me.grdInitCredInv.CellRenderers("Currency").Control
c.ContextMenu = New ContextMenu
Dim c As Control = Me.grdInitCredInv.CellRenderers("Currency").Control
c.ContextMenu.MenuItems(4).Shortcut = Shortcut.None
Another solution to this problem is to have your own ContextMenu associated with the cell control. In that case, you could keep the hot key but in your handler for the menu item, you can catch the exception.
Dim c As Control = Me.grdInitCredInv.CellRenderers("Currency").Control
c.ContextMenu = (New TextBox).ContextMenu
If (((Keys.Control And Control.ModifierKeys) <> 0) Or Char.IsLetter(e.KeyChar) And (Asc(e.KeyChar) = 120 Or Asc(e.KeyChar) = 88)) Or (AscW(e.KeyChar) = Keys.Back) Then
As far as the button''s go, it is the embedded textbox control that handles copying and pasting a single cell. Not the grid. So maybe try code like
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim tb As TextBox = Me.grdAGCY_RR.CurrentCell.Renderer.Control tb.Focus() tb.Copy() ''grdAGCY_RR.Model.CutPaste.Copy() End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Dim tb As TextBox = Me.grdAGCY_RR.CurrentCell.Renderer.Control tb.Focus() tb.Paste() '' grdAGCY_RR.Model.CutPaste.Paste() End Sub
Private Sub MenuItem2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem2.Click Dim editing As Boolean = False If Not Me.grdAGCY_RR.CurrentCell.IsEditing _ And Me.grdAGCY_RR.Selections.Ranges.ActiveRange.Width = 1 _ And Me.grdAGCY_RR.Selections.Ranges.ActiveRange.Height = 1 Then Me.grdAGCY_RR.CurrentCell.BeginEdit() Dim tb As TextBox = Me.grdAGCY_RR.CurrentCell.Renderer.Control tb.SelectAll() editing = True End If SendKeys.Send("^C") If editing Then Me.grdAGCY_RR.CurrentCell.EndEdit() End If End Sub Private Sub MenuItem3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem3.Click Dim editing As Boolean = False If Not Me.grdAGCY_RR.CurrentCell.IsEditing _ And Me.grdAGCY_RR.Selections.Ranges.ActiveRange.Width = 1 _ And Me.grdAGCY_RR.Selections.Ranges.ActiveRange.Height = 1 Then Me.grdAGCY_RR.CurrentCell.BeginEdit() Dim tb As TextBox = Me.grdAGCY_RR.CurrentCell.Renderer.Control tb.SelectAll() editing = True End If SendKeys.Send("^V") If editing Then Me.grdAGCY_RR.CurrentCell.EndEdit() End If End Sub
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.
This page will automatically be redirected to the sign-in page in 10 seconds.