473,320 Members | 2,110 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,320 software developers and data experts.

forcing combobox elements

Hello,
I have a C# project with a windows Form. In the form I have a ComboBox. I
would like to force the user to choose one of the entries in the combobox,
and not allow him/her to edit the content of the entry chosen.
Is this possible in some easy and elegant way?

thanks,
--
dshemesh
May 28 '07 #1
4 1424
On Mon, 28 May 2007 14:41:00 +0200, dshemesh <ds******@discussions.microsoft.comwrote:
Hello,
I have a C# project with a windows Form. In the form I have a ComboBox.. I
would like to force the user to choose one of the entries in the combobox,
and not allow him/her to edit the content of the entry chosen.
Is this possible in some easy and elegant way?

thanks,

Sure is, just specify DropDownStyle = ComboBoxStyle.DropDownList
--
Happy coding!
Morten Wennevik [C# MVP]
May 28 '07 #2
Thanks, that's great.
Is there a way to set a default value when the form opens?

thanks again,
--
dshemesh
"Morten Wennevik [C# MVP]" wrote:
On Mon, 28 May 2007 14:41:00 +0200, dshemesh <ds******@discussions.microsoft.comwrote:
Hello,
I have a C# project with a windows Form. In the form I have a ComboBox.. I
would like to force the user to choose one of the entries in the combobox,
and not allow him/her to edit the content of the entry chosen.
Is this possible in some easy and elegant way?

thanks,


Sure is, just specify DropDownStyle = ComboBoxStyle.DropDownList
--
Happy coding!
Morten Wennevik [C# MVP]
May 28 '07 #3
On Mon, 28 May 2007 15:34:01 +0200, dshemesh <ds******@discussions.microsoft.comwrote:
Thanks, that's great.
Is there a way to set a default value when the form opens?

thanks again,
Set SelectedIndex on the ComboBox. You can do that in the Form.Load event or after InitializeComponent in the constructor. Specify -1 to clear the selection.

--
Happy coding!
Morten Wennevik [C# MVP]
May 28 '07 #4
Great!
thanks!
--
dshemesh
"Morten Wennevik [C# MVP]" wrote:
On Mon, 28 May 2007 15:34:01 +0200, dshemesh <ds******@discussions.microsoft.comwrote:
Thanks, that's great.
Is there a way to set a default value when the form opens?

thanks again,

Set SelectedIndex on the ComboBox. You can do that in the Form.Load event or after InitializeComponent in the constructor. Specify -1 to clear the selection.

--
Happy coding!
Morten Wennevik [C# MVP]
May 28 '07 #5

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

Similar topics

2
by: Subhakant | last post by:
Hi, I got a problem while renendering a menu and combobox on a page. The problem is stated below. As per my requirement I have to display a menu on top of the page and a combo box just below...
1
by: Rachel Suddeth | last post by:
When I put a ComboBox on a form, I can enter strings through the designer to fill Items collections. I have put a ComboBox in a UserControl, and exposed the the Items collections with the same...
0
by: Miki T via .NET 247 | last post by:
Hi, I'm trying to "connect" a combobox with a simple Access 2000 database. The objective is to show the elements contained in a column of the DataBase (just a simple Datatable). Should be that...
2
by: tureypr | last post by:
Hello Wolrd! I'm trying to add items. to a comboox from a XML file, I want to add the parents elements to thre combobox and when you select an item in the combobox, in a another combobox...
6
by: Sakharam Phapale | last post by:
Hi All, How to fill one ComboBox from other ComboBox control? 1) Only setting the reference does the trick but doesn't show items in control. If you see in immediate window, it shows...
14
by: Chris | last post by:
I have a need to have a combo box that just has Yes & No as it options. This will be used everywhere in the application, so I thought I would make a control that inherits from combobox. I am...
0
by: daveg | last post by:
Hi In VB.Net, If you click on a combobox and make a selection, the combobox stays selected, and you can still change the value with you mouse scroll wheel. Does anyone know how to make a...
1
by: =?Utf-8?B?RWl0YW4=?= | last post by:
Hello, I have a ComboBox named comboBoxSelChannel. I declared a structure named MySturct. public struct MyStruct { public int Index; public string Name;
6
by: Peter Larsen [CPH] | last post by:
Hi, How do i set DropDownWith in a asp.net ComboBox ?? Thank you in advance. BR Peter
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.