473,387 Members | 1,476 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,387 software developers and data experts.

Disabling form controls

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
16 1306
ISK
try the readonly property thats on textbox..i'm not sure there's one for comboboxes..
Nov 20 '05 #2
* =?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
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
-----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
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
* "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
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
* "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
> >> 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
* "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
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
* "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
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
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
> * "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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: ML.Steve | last post by:
Hi, There are lots of posts on this subject but after a couple of hours of going though them I still can't get a number of fields to be disabled when a checkbox is ticked. Basically I have a...
1
by: Jason Galvin | last post by:
I would like to disable the auto-populating feature (remembers form element text between post-backs) when creating a .NET form. I have succeeded in disabling auto-populate by creating my controls...
4
by: Dan =o\) | last post by:
Hi guys, in the scenario where a user fills in a form, and clicks on a button to Save, there's a period of waiting (the slower the connection between client and server, the longer the delay)...
4
by: louise raisbeck | last post by:
Hi there, I have put some web controls, textboxes and drop down lists, in a Panel, so that under a certain condition i can disable all fields for input. I read in Help that disabling a Panel...
7
by: John Meyer | last post by:
I have a program where I have to enable or disable a list box based upon a radio button. Is there an "enabled" property on select boxes?
2
by: dm1608 | last post by:
I have to issues: 1) Does anyone know of a programmatic way I can disable all textboxes, combo, listboxes, and buttons on a form? 2) What is the best practice for disabling multiple controls...
1
by: Robert | last post by:
I borrowed one of the forms from the MS Access Solutions database and altered it to fit my needs. The form was the 'EditProducts' form where you select a category from a combo which then populates...
11
by: shankwheat | last post by:
I have a function which passes text from txtdebt to debtsbox which works fine. However, I want to add code which examines the value of debtsbox and if any of the values the user entered contain the...
5
by: jehugaleahsa | last post by:
Hello: I am sure this question comes up a lot. I need to disable the controls on my Windows forms so that when the BindingSource is empty some the controls bound to it will be disabled. This...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...

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.