I'm creating an autotext facility in a richtextbox (like in Word where entries like "Yours faithfully" are suggested with a tooltip). If the user clicks away from the richtextbox then then the autotext suggestion should vanish. But this is easier said than done. The richtextbox's leave and lost focus events don't occur if the user clicks on the parent form for instance. I can approach the problem by capturing the mouse as follows:
but then initial clicks on buttons etc. are not recognised, which isn't very good. I can't believe that something that should be so simple is so problematic. Any suggestions?
Visual Basic:
Private Sub RichTextBox1_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles RichTextBox1.KeyUp
Me.RichTextBox1.Capture = True
Me.RichTextBox1.Cursor = Cursors.Default 'I'm sure this line shouldn't be necessary, but without it the cursor disappears!
End Sub
but then initial clicks on buttons etc. are not recognised, which isn't very good. I can't believe that something that should be so simple is so problematic. Any suggestions?