473,396 Members | 1,608 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Keep a TextBox from displaying its caret (cursor)?

How do you keep a TextBox from displaying its caret (blinking vertical line,
insertion point)?

Setting it to ReadOnly doesn't do the job in VS 2005.
Mar 10 '07 #1
9 6338
Ole
If the user isn't allowed to enter text in the TextBox you could use the
label control as an alternative.

Ole
"Michael A. Covington" <lo**@ai.uga.edu.for.addresswrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
How do you keep a TextBox from displaying its caret (blinking vertical
line, insertion point)?

Setting it to ReadOnly doesn't do the job in VS 2005.


Mar 10 '07 #2
VJ
The below will do it..

[DllImport("user32")] private static extern bool HideCaret(IntPtr hWnd);

public void HideCaret()
{
HideCaret(TextBox1.Handle);
}

"Michael A. Covington" <lo**@ai.uga.edu.for.addresswrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
How do you keep a TextBox from displaying its caret (blinking vertical
line, insertion point)?

Setting it to ReadOnly doesn't do the job in VS 2005.


Mar 10 '07 #3

"Ole" <ol*@blabla.comwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
If the user isn't allowed to enter text in the TextBox you could use the
label control as an alternative.
It needs to be multiline. My impression was that labels are always only 1
line.

But thanks.
Mar 10 '07 #4

"VJ" <no***********@yahoo.comwrote in message
news:eH**************@TK2MSFTNGP03.phx.gbl...
The below will do it..

[DllImport("user32")] private static extern bool HideCaret(IntPtr hWnd);

public void HideCaret()
{
HideCaret(TextBox1.Handle);
}
Thanks, but as far as I can tell, this has no effect. When should it be
done? Immediately after AppendText?
Mar 10 '07 #5
VJ
Michael.. I have done the below in text changed as well as lost foucs, never
had any issues. Is there a sample code you can give that has the problem?

"Michael A. Covington" <lo**@ai.uga.edu.for.addresswrote in message
news:u8**************@TK2MSFTNGP04.phx.gbl...
>
"VJ" <no***********@yahoo.comwrote in message
news:eH**************@TK2MSFTNGP03.phx.gbl...
>The below will do it..

[DllImport("user32")] private static extern bool HideCaret(IntPtr hWnd);

public void HideCaret()
{
HideCaret(TextBox1.Handle);
}

Thanks, but as far as I can tell, this has no effect. When should it be
done? Immediately after AppendText?


Mar 10 '07 #6
VJ
Sorry about that, this should not be done in lost focus. Yes I have done in
text changed it has worked, just checked out and it worked

VJ

"VJ" <no***********@yahoo.comwrote in message
news:ed**************@TK2MSFTNGP02.phx.gbl...
Michael.. I have done the below in text changed as well as lost foucs,
never had any issues. Is there a sample code you can give that has the
problem?

"Michael A. Covington" <lo**@ai.uga.edu.for.addresswrote in message
news:u8**************@TK2MSFTNGP04.phx.gbl...
>>
"VJ" <no***********@yahoo.comwrote in message
news:eH**************@TK2MSFTNGP03.phx.gbl...
>>The below will do it..

[DllImport("user32")] private static extern bool HideCaret(IntPtr hWnd);

public void HideCaret()
{
HideCaret(TextBox1.Handle);
}

Thanks, but as far as I can tell, this has no effect. When should it be
done? Immediately after AppendText?



Mar 11 '07 #7
I'll try doing it in the TextChanged event. Thanks.

"VJ" <no***********@yahoo.comwrote in message
news:e7****************@TK2MSFTNGP05.phx.gbl...
Sorry about that, this should not be done in lost focus. Yes I have done
in text changed it has worked, just checked out and it worked

VJ

"VJ" <no***********@yahoo.comwrote in message
news:ed**************@TK2MSFTNGP02.phx.gbl...
>Michael.. I have done the below in text changed as well as lost foucs,
never had any issues. Is there a sample code you can give that has the
problem?

"Michael A. Covington" <lo**@ai.uga.edu.for.addresswrote in message
news:u8**************@TK2MSFTNGP04.phx.gbl...
>>>
"VJ" <no***********@yahoo.comwrote in message
news:eH**************@TK2MSFTNGP03.phx.gbl...
The below will do it..

[DllImport("user32")] private static extern bool HideCaret(IntPtr
hWnd);

public void HideCaret()
{
HideCaret(TextBox1.Handle);
}
Thanks, but as far as I can tell, this has no effect. When should it be
done? Immediately after AppendText?




Mar 11 '07 #8
Ole
It needs to be multiline. My impression was that labels are always only 1
line.

But thanks.
There is no problem in writing multiple lines in a label.

Ole
Mar 11 '07 #9
Ole
There is no problem in writing multiple lines in a label.
>
Ole
try this (create a form with a label on):
public Form1()
{
InitializeComponent();
label1.Text = "This label has two" + Environment.NewLine + "lines, and
could be more";
}

Ole
Mar 11 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Hector Martinez | last post by:
I need to know the position of the cursor inside the TextBox. How Can I do that Thanks in advantage...
7
by: Mel Weaver | last post by:
Hello, How do you scroll to the bottom of a multiline textbox in code? Mel
3
by: bitwxtadpl | last post by:
I want to programmatically set the position of a cursor in a textbox that has focus based on a X and Y value. However, when I send a WM_RBUTTONDOWN and a WM_RBUTTONUP message to the textbox it...
22
by: DraguVaso | last post by:
Hi, For my application I need the following behavior: When I press F4 the cursor has to move to the next line in my multiline textbox which begins with "0". Finding lines starting with 0 isn't...
0
by: Oenone | last post by:
I would like to set the caret position in a (single-line) textbox to a position based on the number of pixels from the left of the control. For example, I want the caret to be positioned 50...
3
by: Doug Bell | last post by:
Hi, How do I get the position of the cursor (as character position) when it is in a text box with no text selected? Thanks Doug
5
by: kusanagihk | last post by:
To all, I've got a problem using Javascript to control the properties of a html textbox. I was wondering if I could change the cursor index / position of the text within a textbox object. ...
3
by: fbergroth | last post by:
Hi, I'm quite new to C# allthough I've been programming in other languages for quite a while. I'd like to change the blinking cursor inside a TextBox, I guess I must derive the class and...
8
by: nil | last post by:
Hello all, It's urgent... i want to add autocomplete textbox facility in my application like google. as you type it suggests option to the user..i want the same kind of facility...i know i...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.