![]() | Type | Description | ||
| Start as Long | A long expression that indicates the starting of the context | |||
| Context as String | A string expression that defines the context. |
The OnContext event notifies your application that user invokes the control's context window. By default, the control displays the context window if the user presses the CTRL + SPACE combination. Use the ContextKey property to define the key combination that's used to display the control's context window. The version 1.0.3.4 introduces the OnContext event that's fired if the control is not read only, and the user opens the control's context menu ( pressing the CTRL + SPACE key combination ). The OnContext event passes the context string and the position where the context begins. Use the OnContext event to notify your application that the user asks for a context. For instance, during the OnContext event you can add a collection of the items, based on the context you have, using the Add method of the Context object. Use the CaretPos and CaretLine properties to determine the position of the cursor inside the text. Use the TextLine property to retrieve line at the cursor.
The following VB sample displays the current line when the OnContext event occurs:
Private Sub Edit1_OnContext(ByVal Start As Long, ByVal Context As String)
With Edit1
Debug.Print "Current line: " & .TextLine(.CaretLine)
End With
End Sub
The following C++ sample displays the current line when the OnContext event occurs:
void OnOnContextEdit1(long Start, LPCTSTR Context)
{
OutputDebugString( m_edit.GetTextLine( m_edit.GetCaretLine() ) );
}
The following VB.NET sample displays the current line when the OnContext event occurs:
Private Sub AxEdit1_OnContext(ByVal sender As Object, ByVal e As AxEXEDITLib._IEditEvents_OnContextEvent) Handles AxEdit1.OnContext
With AxEdit1
Debug.WriteLine(.get_TextLine(.CaretLine))
End With
End Sub
The following C# sample displays the current line when the OnContext event occurs:
private void axEdit1_OnContext(object sender, AxEXEDITLib._IEditEvents_OnContextEvent e)
{
System.Diagnostics.Debug.WriteLine(axEdit1.get_TextLine(axEdit1.CaretLine));
}
The following VFP sample displays the current line when the OnContext event occurs:
*** ActiveX Control Event *** LPARAMETERS start, context with thisform.Edit1 wait window nowait .TextLine(.CaretLine) endwith