Lose selection

Graham

Member
Joined
Feb 17, 2007
Messages
13
Programming Experience
5-10
I have a simple text editor, my problem is that if I select some text by dragging the mouse over it, and then go to select a different font from a drop down combo box the highlight vanishes from around the text, how can I keep the text highlighted when the form loses focus?
 
Is this property interesting?:
HideSelection Gets or sets a value indicating whether the selected text in the text box control remains highlighted when the control loses focus. (Inherited from TextBoxBase.)
 
Thanks John,
That property was very interesting :)
At first I tried ;

VB.NET:
Private Sub rtbText_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles rtbText.GotFocus
        rtbText.HideSelection = True
    End Sub
    Private Sub rtbText_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles rtbText.LostFocus
        rtbText.HideSelection = False
    End Sub
Which didn't work, so I placed this in the form load event

VB.NET:
rtbText.HideSelection = False
and all works well.
 
This property is available in Designer also, so you don't have to write code for it.
 
Back
Top