Hey All

I have a multi-line text box that tells the user to perform an action. When the form loads, as the text box is the only control on the form, it is highlighted. This may be a silly question, but is it possible to disable the text box from being highlighted? Ideally it would be great if I could disable the text from being selected all together? Any suggestions would be great. Is there another control that would achieve what I'm trying to do?

Many thanks

Cameron

Hey avirag thanks for your reply. I still want the text box to be visible and display the text, but not able to be selected. Any ideas? Thanks.

sorry i don't have any idea of this, may be any other daniweb member have any idea of this.....

Hint:
1. READ ALL the PROPERTIES built into your objects.
2. UNDERSTAND them.
However, once you've read a property name like ReadOnly, how hard would that property be to understand?

Thanks for your replies. This still doesn't solve the problem unfortunately. I do understand the ReadOnly property, it does disable the control from being written to, however unless I'm mistaken, the text can still be selected. This is what I am trying to disable. Any hints that would help me solve this problem, would be appreciated. I guess what I'm after is a Multiline label, or something similar. Cheers.

>but is it possible to disable the text box from being highlighted?
Use Label control or Disabled the TextControl.

Tell us what you are trying to do?

>but is it possible to disable the text box from being highlighted?
Use Label control or Disabled the TextControl.

Tell us what you are trying to do?

The label control is what I'm after, using the '\n' character solves my problem and allows multiple lines of text. Thanks everyone.

Hey All

I have a multi-line text box that tells the user to perform an action. When the form loads, as the text box is the only control on the form, it is highlighted. This may be a silly question, but is it possible to disable the text box from being highlighted? Ideally it would be great if I could disable the text from being selected all together? Any suggestions would be great. Is there another control that would achieve what I'm trying to do?

Many thanks

Cameron

Sorry, didn't read your text closely. Glad the Label fixed your problem. When I bring up my app, the text box fields aren't highlighted or selectable at all using the read only attribute. But I have a button and a combo box on the form. When I use the combo box some of the text boxes become selectable. How do you navigate on your form if you give the user absolutely no way of communicating with the form?

You can use this method when the form load to deselect the text

textBox1.Select(0, -1);

- Set the TextBox to be unSelectable :
the TextBox CanSelect is readOnly property and it set to true,
and when this property is set to true it's mean that this control can be focused and selectable.
The label Control CanSelect property is set to false so you may use label control to display the data and can't be selectable by the user at all.

Ok so if have this same problem. I'm using textbox to allow users to enter notes which is saved to the DB. When a users selects a customer to view their notes, all the text in the textbox is highlighted when the form loads. I'm afraid they will mistakingly delete all the text if they only want to modify or add additional notes.
So is the solution for this that i should be using a label??

Sailor_Jerry; You can use a label, you can set the TextBox "ReadOnly" property to true so it acts like a label, you can use the method Mahmoud suggested. There are a multitude of options available, all that is required is that you have the ability to read. Failing that, I fail to see how anyone can help you.

Sailor_Jerry; You can use a label, you can set the TextBox "ReadOnly" property to true so it acts like a label, you can use the method Mahmoud suggested. There are a multitude of options available, all that is required is that you have the ability to read. Failing that, I fail to see how anyone can help you.

What good would setting the TextBox ReadOnly property to true do? Can you read?
Mahmoud had the correct solution for me, I thank Mahmoud for polite and helpful answer.

HINT:
You on the other hand, from reading your other replies are a condescending prick

I think that what you realy need to do is set the TabStop property to false.
This is used by forms to determine what items can have focus.
The first object in the Tab Order (i.e. TabIndex = 0) with TabStop true is the object that gets focus when the form opens.
If there are no objects with TabStop true then the form has the focus.

Hey All

I have a multi-line text box that tells the user to perform an action. When the form loads, as the text box is the only control on the form, it is highlighted. This may be a silly question, but is it possible to disable the text box from being highlighted? Ideally it would be great if I could disable the text from being selected all together? Any suggestions would be great. Is there another control that would achieve what I'm trying to do?

Many thanks

Cameron

private void cTextBox1_KeyDown(object sender, KeyEventArgs e)
        {
            if (cTextBox1.SelectedText.Length > 0)
            {
                cTextBox1.SelectionLength = 0;
            }
        }

        private void cTextBox1_MouseClick(object sender, MouseEventArgs e)
        {
            cTextBox1_KeyDown(null, null);
        }

This will surely help you.
Thanks

Edited 6 Years Ago by __avd: Added [code] tags.

This article has been dead for over six months. Start a new discussion instead.