Disabling form controls

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Is it possible to disable a form control (eg. text box) without affecting it's foreground and background colors
(I want it to look the same, but disallow user input.

Miriam
 
* =?Utf-8?B?TWlyaWFt?= said:
Is it possible to disable a form control (eg. text box) without affecting it's foreground and background colors?
(I want it to look the same, but disallow user input.)

At least for the textbox: Set its 'ReadOnly' property to 'True' and
reset forecolor and backcolor.

The better way is to change the system's color settings :-).
 
you dont even need to change the fore/back colors.

----- Herfried K. Wagner [MVP] wrote: ----

* =?Utf-8?B?TWlyaWFt?= said:
Is it possible to disable a form control (eg. text box) without affecting it's foreground and background colors
(I want it to look the same, but disallow user input.

At least for the textbox: Set its 'ReadOnly' property to 'True' an
reset forecolor and backcolor

The better way is to change the system's color settings :-)
 
-----Original Message-----
* =?Utf-8?B?TWlyaWFt?=

At least for the textbox: Set its 'ReadOnly' property to 'True' and
reset forecolor and backcolor.

The better way is to change the system's color settings :- ).

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
.
there is an alternative to the above
add a handler to the gotfocus event, i.e.
if you have a textbox that you want to disable then make a
sub , like.. sub disable(sender as object , e as EventArgs)
Object.Focus()
end Sub
where Object is a control that is not disabled
And ....... Addhandler textbox.GotFocus,Addressof Disable
.......
If you want to enable it again then ...RemoveHandler.....
 
Hi ISK,
try the readonly property thats on textbox..i'm not sure there's one for
comboboxes.

Does that disable the combobox or does it preserve only entering text.

In my opinion you can do still a lot of choises although it is readonly?

Cor
 
* "Cor Ligthert said:
comboboxes.

Does that disable the combobox or does it preserve only entering text.

In my opinion you can do still a lot of choises although it is readonly?

The combobox doesn't have a 'ReadOnly' property.
 
Hi Herfried,
The combobox doesn't have a 'ReadOnly' property.
Try dropdownstyle = comboboxStyle.dropdownlist

It is not written the same as with the textbox, however it makes the
combobox.textbox readonly.

Cor
 
* "Cor Ligthert said:
Try dropdownstyle = comboboxStyle.dropdownlist

It is not written the same as with the textbox, however it makes the
combobox.textbox readonly.

ACK, but I would not consider that to be "read only". The purpose of a
combobox is to select an item from a bunch of items. Changing
'DropDownStyle' only changes the way the user can choose an item, but it
doesn't prevent the user from selecting an item. So the control isn't
readonly or disabled.
 
The combobox doesn't have a 'ReadOnly' property.
ACK, but I would not consider that to be "read only". The purpose of a
combobox is to select an item from a bunch of items. Changing
'DropDownStyle' only changes the way the user can choose an item, but it
doesn't prevent the user from selecting an item. So the control isn't
readonly or disabled.

No that is not true Herfried, I stayed as what I wrote in my first answer in
this message, it is readonly however not disabled, the events are still
fired and the selections can be made.

Cor
 
* "Cor Ligthert said:
No that is not true Herfried, I stayed as what I wrote in my first answer in
this message, it is readonly however not disabled, the events are still
fired and the selections can be made.

That's why it's not read-only. There is no textbox in a combobox with
'DropDownStyle' set to 'DropDownList'.

Just my 2 Euro cents...
 
Hi Herfried,
That's why it's not read-only. There is no textbox in a combobox with
'DropDownStyle' set to 'DropDownList'.

Just my 2 Euro cents...

What is than the name of that box in the top of that where you can get the
data from with myitem = combobox.text?

Cor
 
* "Cor Ligthert said:
What is than the name of that box in the top of that where you can get the
data from with myitem = combobox.text?

It's not a textbox. Or do you want to tell me that labels are textboxes
too?

SCNR and my 2 Euro cents again...
 
* "Cor Ligthert said:
The control has a textbox part only if its style isn't set to
'DropDownList'. If it's set to 'DropDownList', there is no textbox.
No what is than the name of it, Or do you mean that a texbox which is set to
read only is a label.

For me that sounds strange, however I have heard strange logical thinking
before?

Cor
 
Cor,

* "Cor Ligthert said:
No what is than the name of it, Or do you mean that a texbox which is set to
read only is a label.

It doesn't have a name, it's a 'DropDownList' style combobox ;-). I
don't mean that a read only textbox is a label -- there is no textbox at
all.
For me that sounds strange, however I have heard strange logical thinking
before?

:-)
 
Back
Top