Type | Description | |||
Options as Variant | Optional. If missing, the control edits the focused cell. A long expression that indicates the handle of a locked item. Use the LockedItem property to retrieve the handle of a locked/fixed item. |
The Edit method starts editing the focused cell, if the cell has an editor assigned. Use the Editor property of the Column object, or CellEditor property to assign an editor to a cell. The focused cell is determined by the intersection of the focused item and the focused column. Use the FocusItem property to get the handle of the focused item. Use the FocusColumnIndex property to determine the index of the focused column. The control fires the Edit event when the edit operation is about to start. The edit operation doesn't start if the control's ReadOnly property is True, or if the cell's editor is hidden ( CellEditorVisible property is False ). Use the Editing property to check whether the control is in edit mode, or to get the window's handle for the built-in editor that's visible and focused. The EditClose method closes the current editor. Use the ValidateValue event to validate the values that user enters.
The edit events are fired in the following order:
Edit event. Prevents editing cells, before showing the cell's editor.
EditOpen event. The edit operation started, the cell's editor is shown. The Editing property gives the window's handle of the built-in editor being started.
Change event. The Change event is fired only if the user types ENTER key, or the user selects a new value from a predefined data list.
EditClose event. The cell's editor is hidden and closed.
If the Options parameter is missing, the control edits the focused cell. The FocusItem and FocusColumnIndex properties indicates the focused cell. If the Options parameter is present, the control edits the item that Options parameter indicates.
For instance, the following VB sample edits a locked item when the user clicks a cell:
Private Sub G2antt1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single) With G2antt1 If Button = 1 Then Dim h As EXG2ANTTLibCtl.HITEM, c As Long, hit As EXG2ANTTLibCtl.HitTestInfoEnum h = .ItemFromPoint(X / Screen.TwipsPerPixelX, Y / Screen.TwipsPerPixelY, c, hit) If Not h = 0 Then If (.Items.IsItemLocked(h)) Then .FocusColumnIndex = c .Edit h End If End If End If End With End Sub
Call the DoEvents (Processes all Windows messages currently in the message queue) method after Edit method to start immediately the edit operation.
The following C++ sample edits edits a locked item when the user clicks a cell:
void OnMouseUpG2antt1(short Button, short Shift, long X, long Y) { CItems items = m_g2antt.GetItems(); long c = 0, hit = 0, h = m_g2antt.GetItemFromPoint( X, Y, &c, &hit); if ( h != 0 ) if ( items.GetIsItemLocked( h ) ) { m_g2antt.SetFocusColumnIndex( c ); m_g2antt.Edit( COleVariant( h ) ); } }
The following VB.NET sample edits edits a locked item when the user clicks a cell:
Private Sub AxG2antt1_MouseUpEvent(ByVal sender As Object, ByVal e As AxEXG2ANTTLib._IG2anttEvents_MouseUpEvent) Handles AxG2antt1.MouseUpEvent With AxG2antt1 Dim i As Integer, c As Integer, hit As EXG2ANTTLib.HitTestInfoEnum i = .get_ItemFromPoint(e.x, e.y, c, hit) If (Not (i = 0)) Then If (.Items.IsItemLocked(i)) Then .FocusColumnIndex = c .Edit(i) End If End If End With End Sub
The following C# sample edits edits a locked item when the user clicks a cell:
private void axG2antt1_MouseUpEvent(object sender, AxEXG2ANTTLib._IG2anttEvents_MouseUpEvent e) { int c = 0; EXG2ANTTLib.HitTestInfoEnum hit; int i = axG2antt1.get_ItemFromPoint(e.x, e.y, out c, out hit); if (i != 0) { if ( axG2antt1.Items.get_IsItemLocked( i ) ) { axG2antt1.FocusColumnIndex = c; axG2antt1.Edit(i); } } }
The following VFP sample edits edits a locked item when the user clicks a cell:
*** ActiveX Control Event *** LPARAMETERS button, shift, x, y local c, hit c = 0 hit = 0 with thisform.G2antt1 .Items.DefaultItem = .ItemFromPoint( x, y, @c, @hit ) if ( .Items.DefaultItem <> 0 ) if ( .Items.IsItemLocked(0) ) .FocusColumnIndex = c .Object.Edit(.Items.DefaultItem) endif endif endwith