property Edit.SelText as String
Returns or sets the string containing the currently selected text.

 TypeDescription 
   String A string expression that indicates the  current selection's text.  

Returns the text that the user selected in a text-entry area of a control, or returns an empty string ("") if no characters are selected. Specifies the string containing the selected text. Not available at design time; read-write at run time. Use the CaretPos and CaretLine properties to get the control's caret position. Use the SelectLine method to select a line by code. Use the GetSelection method to determine the coordinates of the selected text. The SelStart property returns or sets the starting point of text selected; indicates the position of the insertion point if no text is selected. The control fires the SelChange event when the user changes the selection.

The following VB sample displays the selected text when the user changes it:

Private Sub Edit1_SelChange()
    If Not Edit1.SelText = "" Then
        Debug.Print Edit1.SelText
    End If
End Sub

The following C++ sample displays the selected text when the user changes it:

void OnSelChangeEdit1() 
{
	OutputDebugString( m_edit.GetSelText() );
}

The following VB.NET sample displays the selected text when the user changes it:

Private Sub AxEdit1_SelChange(ByVal sender As Object, ByVal e As System.EventArgs) Handles AxEdit1.SelChange
    With AxEdit1
        Debug.WriteLine(.SelText)
    End With
End Sub

The following C# sample displays the selected text when the user changes it:

private void axEdit1_SelChange(object sender, EventArgs e)
{
	System.Diagnostics.Debug.WriteLine(axEdit1.SelText);
}

The following VFP sample displays the selected text when the user changes it:

*** ActiveX Control Event ***

with thisform.Edit1
	wait window nowait .SelText
endwith

 


Send comments on this topic.
1999-2016 Exontrol.COM, Software. All rights reserved.