By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,131 Members | 1,072 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,131 IT Pros & Developers. It's quick & easy.

Disabling form controls

P: n/a
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
Nov 20 '05 #1
Share this Question
Share on Google+
16 Replies


P: n/a
ISK
try the readonly property thats on textbox..i'm not sure there's one for comboboxes..
Nov 20 '05 #2

P: n/a
* =?Utf-8?B?TWlyaWFt?= <an*******@discussions.microsoft.com> scripsit:
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 :-).

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #3

P: n/a
ISK
you dont even need to change the fore/back colors.

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

* =?Utf-8?B?TWlyaWFt?= <an*******@discussions.microsoft.com> scripsit
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 :-)

--
Herfried K. Wagner [MVP
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #4

P: n/a
-----Original Message-----
* =?Utf-8?B?TWlyaWFt?= <an*******@discussions.microsoft.com> scripsit:
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' andreset 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.....
Nov 20 '05 #5

P: n/a
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
Nov 20 '05 #6

P: n/a
* "Cor Ligthert" <no**********@planet.nl> scripsit:
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?


The combobox doesn't have a 'ReadOnly' property.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #7

P: n/a
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
Nov 20 '05 #8

P: n/a
* "Cor Ligthert" <no**********@planet.nl> scripsit:
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.


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.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #9

P: n/a
> >> 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.


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
Nov 20 '05 #10

P: n/a
* "Cor Ligthert" <no**********@planet.nl> scripsit:
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.


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...

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #11

P: n/a
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
Nov 20 '05 #12

P: n/a
* "Cor Ligthert" <no**********@planet.nl> scripsit:
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?


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

SCNR and my 2 Euro cents again...

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #13

P: n/a
Hi Herfried,

You should complain at Microsoft, if seems that someone is sending with your
name.
It's not a textbox. Or do you want to tell me that labels are textboxes
too?

http://www.google.com/gr*************************@ID-208219.news.uni-berlin.de

:-)

I am curious for your next answer on this?

Cor
Nov 20 '05 #14

P: n/a
Cor,

* "Cor Ligthert" <no**********@planet.nl> scripsit:
You should complain at Microsoft, if seems that someone is sending with your
name.
It's not a textbox. Or do you want to tell me that labels are textboxes
too?

http://www.google.com/gr*************************@ID-208219.news.uni-berlin.de

:-)

I am curious for your next answer on this?


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.

:-)

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #15

P: n/a
> * "Cor Ligthert" <no**********@planet.nl> scripsit:
You should complain at Microsoft, if seems that someone is sending with your name.
It's not a textbox. Or do you want to tell me that labels are textboxes too?

http://www.google.com/gr*************************@ID-208219.news.uni-berlin.de
:-)

I am curious for your next answer on this?


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
Nov 20 '05 #16

P: n/a
Cor,

* "Cor Ligthert" <no**********@planet.nl> scripsit:
It's not a textbox. Or do you want to tell me that labels are textboxes
too?
http://www.google.com/gr*************************@ID-208219.news.uni-berlin.de
:-)

I am curious for your next answer on this?
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.


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?


:-)

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #17

This discussion thread is closed

Replies have been disabled for this discussion.