|
-
April 1st, 2005, 05:27 AM
#1
How to make a RichTextBox content not to be able to select?
Hi!
I want to make a RichTextBox content not to be able to be selected.
The problem is that i can't use enable=false, because the RichTextBox is multiline and has scrollbars and if i disable it, then the scrollbars can't be scrolled.
Thanks for yor answer!
-
April 1st, 2005, 05:34 AM
#2
Re: How to make a RichTextBox content not to be able to select?
Do you mean selected or do you mean read only ? There's a 'ReadOnly' property on the rich text box which prevents users from changing the contents.
Darwen.
-
April 1st, 2005, 05:48 AM
#3
Re: How to make a RichTextBox content not to be able to select?
 Originally Posted by darwen
Do you mean selected or do you mean read only ? There's a 'ReadOnly' property on the rich text box which prevents users from changing the contents.
Darwen.
I know about the ReadOnly property, but this doesn't solve the problem. Even with ReadOnly=true the conetent of a rich texbox can be selected.
So, i mean selected.
-
April 4th, 2005, 02:05 AM
#4
Re: How to make a RichTextBox content not to be able to select?
there is no property as yet. you can manually capture mouse down event and key pressed event to determine whether user is trying to select the text.
If you think you CAN, you can, If you think you CAN'T, you are probably right.
Have some nice Idea to share? Write an Article Online or Email to us and You may WIN a Technical Book from CG.
-
April 4th, 2005, 04:50 AM
#5
Re: How to make a RichTextBox content not to be able to select?
 Originally Posted by Andy Tacker
there is no property as yet. you can manually capture mouse down event and key pressed event to determine whether user is trying to select the text.
Yes, this is the solution!
When the user tryes to click in the RichTextBox then i make focus an another component.
-
April 5th, 2005, 01:41 AM
#6
Re: How to make a RichTextBox content not to be able to select?
you can roll your own richtextbox which inherits from richtextbox, and disable the control from ever being able to gain focus:
Code:
public class ViewOnlyRichTextBox : System.Windows.Forms.RichTextBox {
// constants for the message sending
const int WM_SETFOCUS = 0x0007;
const int WM_KILLFOCUS = 0x0008;
protected override void WndProc(ref Message m) {
if(m.Msg == WM_SETFOCUS) m.Msg = WM_KILLFOCUS;
base.WndProc (ref m);
}
}
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
|