Re: Caret in TextBox
From: Paul (paulp_at_online.nospam)
Date: 07/15/04
- Next message: Charles A. Lackman: "Application Deployment"
- Previous message: Linda Chen: "how to change dataGrid default value from "null" to blank"
- In reply to: Herfried K. Wagner [MVP]: "Re: Caret in TextBox"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 15 Jul 2004 08:47:03 -0700
I have now found how to suppress the caret by 'importing' Win32 as follows:
/// <summary>
/// The HideCaret function removes the caret from the screen.
/// </summary>
[DllImport("user32.dll")]
private static extern bool HideCaret(IntPtr hWnd);
and then invoke it as follows:
HideCaret(mainRichTextBox.Handle);
for:
private System.Windows.Forms.RichTextBox mainRichTextBox;
Only problem is that the caret re-appears when the mouse is clicked anywhere in the client area! Hopefully, I will find a way round this one too.
Thanks once again,
Paul
"Herfried K. Wagner [MVP]" wrote:
> * "=?Utf-8?B?UGF1bA==?=" <paulp@online.nospam> scripsit:
> > I am trying to use a 'read-only' TextBox control in c# to display text with the possibility of scrolling it horizontally and vertically. However, I cannot find any easy way of suppressing (making invisible) the caret.
> >
> > The only way of achieving this that I can see is to somehow get a window handle to the control and to then use the HideCaret API call.
> >
> > Is there any easier way? If not, how do I get a handle to the TextBox control?
>
> Add a label control to a panel control with 'AutoScroll' set to 'True'.
>
> --
> Herfried K. Wagner [MVP]
> <URL:http://dotnet.mvps.org/>
>
- Next message: Charles A. Lackman: "Application Deployment"
- Previous message: Linda Chen: "how to change dataGrid default value from "null" to blank"
- In reply to: Herfried K. Wagner [MVP]: "Re: Caret in TextBox"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|