473,396 Members | 1,997 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.

Need a ReadOnly ComboBox

I need a ComboBox that the user cannot directly edit the text portion.
And the user must click the arrow button to display the list portion.

The DropDownList would do the trick but unless I'm doing something wrong,
I can't change the text programmically either.
I don't want the user to change the text but my program must.

Is there a simple way of doing this?
Thanks
Nov 21 '05 #1
6 4150
**Developer** wrote:
I need a ComboBox that the user cannot directly edit the text portion.
And the user must click the arrow button to display the list portion.

The DropDownList would do the trick but unless I'm doing something wrong,
I can't change the text programmically either.
I don't want the user to change the text but my program must.

Is there a simple way of doing this?
Thanks


Haven't tried it myself, but why don't you override the keypress event
of the combo box and ignore all the keystrokes.

Chris
Nov 21 '05 #2
" **Developer**" <RE*************@a-znet.com> schrieb:
I need a ComboBox that the user cannot directly edit the text portion.
And the user must click the arrow button to display the list portion.

The DropDownList would do the trick but unless I'm doing something wrong,
I can't change the text programmically either.
I don't want the user to change the text but my program must.


See:

<URL:http://groups.google.de/group/microsoft.public.dotnet.languages.vb/msg/c32a838f79d4a0e6>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #3
> Haven't tried it myself, but why don't you override the keypress event of
the combo box and ignore all the keystrokes.

Chris


I had tried it except I think it was one of the other Key** Overrides and it
didn't work.
I just did it by overriding KeyPress and it seems to work OK.
Thanks
Nov 21 '05 #4

I had seen that and before I tried it I tried Chris' method and it seems OK,
so I did not pursue that method.

(When I read it I did wonder if it made the text so that the contents could
not be changed even programmatically. For future reference, do you have any
idea?)

Thanks
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:ux**************@TK2MSFTNGP12.phx.gbl...
" **Developer**" <RE*************@a-znet.com> schrieb:
I need a ComboBox that the user cannot directly edit the text portion.
And the user must click the arrow button to display the list portion.

The DropDownList would do the trick but unless I'm doing something wrong,
I can't change the text programmically either.
I don't want the user to change the text but my program must.


See:

<URL:http://groups.google.de/group/microsoft.public.dotnet.languages.vb/msg/c32a838f79d4a0e6>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #5
If a combo box has a style of "Dropdown List", only the items in the list can
be selected and shown in the text portion. I would think the best way to
change the text is to add whatever text you want to the combo box's item
collection then set the selected index to that item...this should cause the
text to be shown in the text box of the combo box.
--
Dennis in Houston
"**Developer**" wrote:

I had seen that and before I tried it I tried Chris' method and it seems OK,
so I did not pursue that method.

(When I read it I did wonder if it made the text so that the contents could
not be changed even programmatically. For future reference, do you have any
idea?)

Thanks
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:ux**************@TK2MSFTNGP12.phx.gbl...
" **Developer**" <RE*************@a-znet.com> schrieb:
I need a ComboBox that the user cannot directly edit the text portion.
And the user must click the arrow button to display the list portion.

The DropDownList would do the trick but unless I'm doing something wrong,
I can't change the text programmically either.
I don't want the user to change the text but my program must.


See:

<URL:http://groups.google.de/group/microsoft.public.dotnet.languages.vb/msg/c32a838f79d4a0e6>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>


Nov 21 '05 #6
That should work because I eventually (after many changes) add it to the
items anyway.

Thanks
"Dennis" <De****@discussions.microsoft.com> wrote in message
news:CB**********************************@microsof t.com...
If a combo box has a style of "Dropdown List", only the items in the list
can
be selected and shown in the text portion. I would think the best way to
change the text is to add whatever text you want to the combo box's item
collection then set the selected index to that item...this should cause
the
text to be shown in the text box of the combo box.
--
Dennis in Houston
"**Developer**" wrote:

I had seen that and before I tried it I tried Chris' method and it seems
OK,
so I did not pursue that method.

(When I read it I did wonder if it made the text so that the contents
could
not be changed even programmatically. For future reference, do you have
any
idea?)

Thanks
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:ux**************@TK2MSFTNGP12.phx.gbl...
>" **Developer**" <RE*************@a-znet.com> schrieb:
>>I need a ComboBox that the user cannot directly edit the text portion.
>> And the user must click the arrow button to display the list portion.
>>
>> The DropDownList would do the trick but unless I'm doing something
>> wrong,
>> I can't change the text programmically either.
>> I don't want the user to change the text but my program must.
>
> See:
>
> <URL:http://groups.google.de/group/microsoft.public.dotnet.languages.vb/msg/c32a838f79d4a0e6>
>
> --
> M S Herfried K. Wagner
> M V P <URL:http://dotnet.mvps.org/>
> V B <URL:http://classicvb.org/petition/>


Nov 21 '05 #7

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

Similar topics

1
by: lasha | last post by:
hi all how can i make combobox and datetimepicker readonly? thank
1
by: ISMAILRAJPUT | last post by:
As i see there is no readonly property for comboBox. Would anyone please help me to have this option ? do i have to inherit this property? or what? and How?
1
by: cashdeskmac | last post by:
I have a combobox which contains the different departments at my work place. However, if the user types another name into the combobox, it is accepted. I wish to allow only the names already...
6
by: moi_bobbo | last post by:
I want to override the existing Combobox class and give it a readonly property so that the backcolor of the combobox will be grey with the forecolor being black as is the case for a textbox set to...
3
by: **Developer** | last post by:
I want to have a ComboBox that is loaded programmically not except keyboard inputs. I tried in KeyDown not calling MyBase.OnKeyDown(e) and also tried setting e.Handled = True but neither appear...
6
by: Roberto | last post by:
Hi, using vb 2005 I'd like to have a combobox in READONLY mode, like I have for textbox. Combobox only has enabled property. When I turn this property false I can not select the text in the...
3
by: Rick Shaw | last post by:
Hi. I am very new to C# and needed help. Use to program in Delphi but switching to C#. I am just starting my very first application and already don't know what to do. Here is what I'm trying to...
0
by: Familjen Karlsson | last post by:
Hi I have downloaded some code and tried it and nothing happens with the datagrid. Explain what is wrong and what I have to do please. I have tried to Import the namespace Hamster and it didn't...
6
by: active | last post by:
I need a combobox where the items are typed as string - not object. And another where the items are from a class I generated. Can one make such comboboxes from System.Windows.Forms.ComboBox?...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.