|
-
Feb 28th, 2009, 12:52 PM
#1
Thread Starter
Addicted Member
WPF RichTextbox - double click word selection
Is there a property or a way to stop words from being selected when i double click?
If i double click on "microsoft" in www.microsoft.com (as a hyperlink in the rtb) microsoft becomes the selected text.
-
Mar 1st, 2009, 11:39 AM
#2
Frenzied Member
Re: WPF RichTextbox - double click word selection
override the doubleclick method and in the method body put some code to let the text selection equal none. You could also just handle the event rather than using override. so:
VB Code:
Private Sub ClearSelection (...) handles myRTB.ondoubleclick
'Stuff
End Sub
personally I would handle the event rather than overriding the original method as it is a cleaner way to code.
-
Mar 2nd, 2009, 06:53 AM
#3
Re: WPF RichTextbox - double click word selection
Of course you can also use XAML to route the event through to your event handler and then you dont need the "handles" statement at the end of the event signature (apparently this is a more 'wpf' way of doing things but I cant actually tell you the advantages in this scenario), then if you had multiple RTBs that you wanted to apply this to then you could specify it in each one (although there is probably a way to do this with a style so you dont have to type it in each RTB declaration):
Code:
<RichTextBox MouseDoubleClick="RichTextBox_MouseDoubleClick" Height="100" Width="200" />
<RichTextBox MouseDoubleClick="RichTextBox_MouseDoubleClick" Height="100" Width="200" />
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|