Click here to Skip to main content
15,887,302 members
Everything / Combobox

Combobox

combobox

Great Reads

by Christoph Buenger
Describes PHP application development with the free Scavix Web Development Framework (Scavix-WDF).
by Nilay M Joshi
Multiselect Combobox - Custom control for WPF
by Johnny J.
A sample owner-drawn ComboBox
by Er. Puneet Goel
This tip implements the TreeView like DropDownList with Search Functionality using Telerik Kendo.

Latest Articles

by vblover Programmer
Custom DropDownBox with all languages of the world to select a language.Save and reload Selected language using Application Settings
by Nilay M Joshi
Multiselect Combobox - Custom control for WPF
by AXI_IeD
How to Filter contextually the list shown by a DataGridComboBoxCell?
by César Jaramillo L.
This is an alternative for "Embedding a DataGridView in a ComboBox"

All Articles

Sort by Title

Combobox 

11 Sep 2013 by Kaveen Abeywansa
I have a combo box with data bounded from a Data Base. I am having problems when adding new items to database and also editing and deleting items. When I do those actions, The combobox is not getting updated until the app restart. I am just a student and I need help for this. I bounded the data...
11 Sep 2013 by norbitrial
It can be a good solution if you put into your form a refresh button and with it you can make a query for your database and rebind the data to your combobox.
11 Sep 2013 by Jean A Brandelero
Just googled for 2 seconds and found this:foreach (Control ctl in this.Controls){ ctl.ResetBindings();}
14 Sep 2013 by Kaveen Abeywansa
Thanks for all who spent their time to help. Even I didn't get the answer, I found the way to do so. I will post it as a help to another beginner like me.SqlConnection con = new SqlConnection(@"PATH");con.Open();SqlCommand cmd = new SqlCommand("select Field from TableName",...
20 Aug 2013 by Michael Waguih
Hi all,I have a combobox binded with items.I want to insert an item to be displayed first to tell the user to choose an item var type = from m_types in DB.Types select m_types; combobox.ValueMember = "Id"; ...
13 Aug 2013 by Dave Kreskowiak
You have to add the item to the datasource you bound the Combo to. Once you bind data to the Combo, you cannot use the Combo's own Items collection.
13 Aug 2013 by abbaspirmoradi
combobox.SelectedValuePath= "Id"; combobox.DisplayMemberPath= "Name"; combobox.ItemsSource= type;combobox.Text="Please choose an item";
13 Aug 2013 by ridoy
Check these solutions,possibly your problem would be solved.insert item in combobox after binding it from a Dataset in c#[^]Add Custom Item after Databinding[^]WinForm ComboBox add text “Select” after data binding[^]
20 Aug 2013 by Michael Waguih
var type = from m_types in DB.Types select m_types; DataTable dt_Types = new DataTable(); dt_Types.Columns.Add("t_ID", typeof(int)); dt_Types.Columns.Add("t_Name", typeof(string)); foreach (var t in...
14 Jul 2015 by Zon-cpp
Hi,I need to create a combo box which shows list of Items contained string (in drop down) when user is typing in edit box of Combo control (OnEditChang).MFC CComboBox Selectes one Item that 'is started' with string is written by user But, I want a combo box that shows list of all items...
18 Jan 2013 by Andrey Sitaev
Here I placed source files, binaries and brief instructions for FastGrid control.
24 Mar 2010 by Alishah Novin
Currently, ComboBoxItems cannot be selected using the keyboard - only the mouse. This is an attempt to resolve that.
14 Sep 2013 by CAS1224
I've been able to change an individual datagridview cell to a combobox in my vb.net windows forms program. Now I'm hoping to find a way to change the entire column to a combobox. Here is my code to change the individual datagridview cells to combobox, the same approach should work but I haven't...
14 Sep 2013 by Jake_L
Would something like this work for you?For cell As Integer = 1 to n Dim myComboBoxCell As New DataGridViewComboBoxCell DataGridView1(3, n) = myComboBoxCell 'Change as neededNext cell
4 Sep 2019 by Member 14532396
I have defined this datagridviewcombobox: Dim lCol2 As New DataGridViewComboBoxColumn lCol2.DataPropertyName = "Descrizione" lCol2.DisplayMember = "Descrizione" lCol2.ValueMember = "IDTessera" lCol2.DisplayIndex = 2 dgwNote.Columns.Add(lCol2) ...
4 Sep 2019 by Gerry Schmitz
DataTable.NewRow Method (System.Data) | Microsoft Docs[^]
19 Aug 2013 by Mobile.Instinct
Hello,I have a 'List' of floats with height and radius values as given below:List WarningRadiusPoints = new List();List WarningHeightPoints = new List();I have multipled files have different files have different lists. For eg: File 1 has 20 height and...
19 Aug 2013 by Sergey Alexandrovich Kryukov
It should not be the list them. It should be a class or a structure with members of different types, such as float, double, integer or whatever else. And then you need to have a list of instanced of such class or structure.—SA
6 Dec 2012 by Member 9522119
I have a program, where I need to add a new item to a combobox sometimes. I did this with this simple code but the problem is, everytime I restart the program, its not there anymore.How can I add somethings so it will be there the next times I open the program too? without a database . ...
6 Dec 2012 by TRK3
Depends on your definition of "database".You have to use some sort of persistent storage to store a flag or list of items to add to your combo box. When the application starts up it needs to read from the persistent storage and populate the combo box. When a new item is added the...
6 Dec 2012 by OriginalGriff
When you start your program, the combo box is filled with the items you specify in the designer. If you want to have other items (say that are saved on program exit and loaded again on start up) then you have to save them somewhere and restore them yourself in the code.The easiest way to do...
15 Aug 2011 by Coder Block
Hello All, I Have little application to drawn different different shapes on client area of window in mfc. Type of shape is selected from toolbar.A shape toolbar is dynamically created depends on the number of images present in "\drawShapes\Img\*" folder.That is if i...
16 Aug 2011 by enhzflep
Something like this perhaps?Toolbars with embedded Combo Boxes[^]
28 May 2010 by Hellraiser123
Hi, I need to create a combo box which provides the auto search feature to a user. Its should behave just like the combo box which we see in the Windows 'Run' dialog or in the windows search dialog. So, as the user types in characters , all the matching strings in the combo box list must be...
25 Aug 2010 by sim099
A colleague of mine is using a combobox extender in an ASP.NET project and has come across a strange issue with it.When there's a lot (say 20 or more) items listed, then the displayed items go off the bottom of the screen and the scroll bar is shown. If there's a smaller number of items...
25 Aug 2010 by Member 3073136
add "overflow-y: auto !important;" into .ajax__combobox_itemlist css class
2 Aug 2013 by Meg Takahashi
Hi All,I have 2 Ajax Toolkit's Comboboxes on my asp.net web page, and I would like to set a value in the 2nd combobox at leaving (losing focus) from the 1st combobox depending on the selection of the 1st combobox. I can capture a lost focus event for a normal text box by adding an attribute...
2 Aug 2013 by Sergey Alexandrovich Kryukov
Yes, the event is called obclur:http://www.w3schools.com/jsref/event_onblur.asp[^].This is how it's done using jQuery: http://api.jquery.com/blur/[^].[EDIT]You actually use onblur but your handler does not do anything useful. What to do? It will depend on what you try to...
8 Aug 2013 by Meg Takahashi
I decided not to use the Ajax combobox for other reasons, but I still figured out how to add 'onBlur' attribute for the combobox. You have to add 'onBlur' attribute to the textbox control in the combobox.controls instead of adding it directly to the combobox itself.Dim txtStartTime As...
22 Aug 2016 by GoodJuJu
I have a comboBox on my ToolStrip that is used to enter search criteria. If the text is longer than the comboBox width (not the drop-down) can display, I would like the user to be able to stretch the left-hand side of the comboBox.I know that I can automatically modify the drop-down width...
10 Jan 2013 by satrio_budidharmawan
Hi all, I have a problem here on my Thinkpad (Android 3.1).I tried to develop web application with android and Gree.But this problem really strange, when I tab combobox for the first time, it's normal. Just like usual combobox, expand it's box and show values of it. But when I tab it for...
11 Nov 2013 by dr_aliragab
I'm looking for an option with which I can view large amount of options in combobox in parallel way !!! sorry for my bad english , but i use photo shop to explain my idea .http://i.stack.imgur.com/214Q0.pngagain the above pic was done by photoshop not with vb :)I use this code two...
13 Nov 2013 by Sergey Alexandrovich Kryukov
Why using a combo box? A well-known multi-column control is System.Windows.Forms.ListView:http://msdn.microsoft.com/en-us/library/system.windows.forms.listview%28v=vs.110%29.aspx[^].There are some other possibilities. You can use two combo boxes bound with events and arranged...
13 Nov 2013 by satyaanupama
i think not possible wth the combo box thankuu
15 Nov 2013 by Tesfamichael G.
I think it is a good idea to shift to WPF. You will be able to manipulate any control to the level of of your desire.Ever since I have shifted to WPF, everything is simple.
16 Nov 2013 by Tesfamichael G.
Try this:msdn.microsoft.com/en-us/library/ee649089(v=vs.110).aspx‎msdn.microsoft.com/en-us/library/ms752299(v=vs.110).aspxmsdn.microsoft.com/en-us/library/vstudio/dd547149.aspx‎msdn.microsoft.com/en-us/library/vstudio/dd465159.aspx‎
21 May 2015 by PClarkeirl
hello,I am using the ComboBox from the AjaxControlToolkit 15.1 in VS2013. However I getting the following error in design mode when I drag the scriptmanager and comboBox to the webform: ComboBox - ComboBox1 there was an error rendering the control. Value...
13 Dec 2017 by Member 13574500
All; I have an issue I'm trying to resolve. How can I try and reproduce the behavior of a ComboBox in ASPx? On my page I have a drop-down populated by a stored procedure and would like to reduce the possible options as the operator is typing. The SP sometimes returns hundreds of results and it...
13 Dec 2017 by Richard Deeming
Getting Started | Select2 - The jQuery replacement for select boxes[^]
18 Mar 2021 by Ishimora1
Hi, essentially im trying to assign a value to whatever the user selects from a combobox. For example, if A is selected then value is set to 1, If b selected then value is 2 etc. The value would then be used to do a multiplication using input...
18 Mar 2021 by Maciej Los
Why to force doors wide open? Please, check this: Bind ComboBox or ListBox Control to Data - Windows Forms .NET Framework | Microsoft Docs[^] For further details, please see: DisplayMember[^] - defines what values are dsiplayed ValueMember[^]...
18 Jan 2011 by astika
I want to assign the Text of a data-bound ComboBox. I tried setting the Text, SelectedValue, and SelectedItem properties but none of them seem to work. I would appreciate suggestions and tips on how best to approach this problem.none of them seem to work means My Work of Assigning Value to...
18 Jan 2011 by Henry Minute
If you mean that you want to provide the contents of the ComboBox dropdown then you need to use the Items property. myComboBox.Items.Add("Some Text"); myComboBox.Items.Add("Some More Text");or string[] items = new string[] { "Some Text", "Some More Text" }; ...
18 Jan 2011 by jerrykid
Hi astika,ComboBox will display Text property when you select an item. And SelectedValue, SelectedItem will have value(s) when only if you set DataSource, DisplayMember, ValueMember property. Please try:cbo.DataSource = dataSet;//Or dataTablecbo.DisplayMember =...
25 Jun 2012 by ridoy
Guy's after trying to autocomplete a textbox i move towards now to an autocomplete combobox.Because i cannot add all controls to a textbox.But in combobox,i did that.But a problem also stands there.When i type in combobox it's popup filters the items according to typed text nicely,but i need to...
26 Jun 2012 by Alexander Oreshkov
FYI, there is nice auto-complete text box in WPF Toolkit (). Why don`t you use it?
6 Apr 2015 by Ikram Khan
In Visual Studio 2012, I have a MultiColumn combo box in WinForms App. I have two columns 'Col_1' and 'Col_2'. 'Col_1' is the display member for combo box. I have set the auto complete property on list items. When I search a keyword in text property of the combo box, it only displays the value...
22 Nov 2011 by nwayynge
Hi Everyone, In my vb.net 2008 Project, I am binding dataset (that include ItemID and ItemName) to combo box (ItemID to ValueMember and ItemName to DisplayMember) that use zaw gyi unicode font. Then i set Auto Complete Mode property of Combo box to "SuggestAppend" and AutoCompleteSource...
2 Jan 2012 by Fu Peng
I think it's because of zawgyi version. How about trying another zawgyi version? It will work.
4 Dec 2012 by heinhtataung
Do u mean Zawgyi font can't display properly at ListItem orCombobox listitem selected value is changing?
29 Dec 2013 by Aung Kyaw Minn
change your project framework to 4.0, it works in framework 4.0
29 Dec 2013 by Dave Kreskowiak
AutoComplete does work since a font cannot possibly affect AutoComplete. AutoComplete compares string values. Strings do not contain any font information at all.
7 Oct 2013 by Delurn
Hey guys,Whats the best way to handle ComboBox Text values that need to translate into an integer.For example if I have a Combobox with 15 or so items, labeled "Item A", "Item B", "Item C", etc. and each one of those need to be translated to an integer, such as Item A = 1016, Item B =...
7 Oct 2013 by idenizeni
// create a class to use for the item pairsclass ComboBoxItem{ public ComboBoxItem(int itemID, string itemText) { ItemID = itemID; ItemText = itemText; } public int ItemID { get; set; } public string ItemText { get; set; }}// in our...
7 Oct 2013 by Sergey Alexandrovich Kryukov
Here is what I advise to do: don't store strings in the combo box items. Who told you that you need to have strings? The runtime type of the list element is...
7 Oct 2013 by BillWoodruff
For contrast to the fine code examples provided by SAK and Idenizeni, here's the "lazy programmer's way" in WinForms:private int ItemNumber;private List cmbItemList = new List { "A", "B", "C", "D" };private List cmbItemCode = new List { 1016, 2422, 8471, 1234...
26 Aug 2021 by dj4400
Hi Sorry in advance for the long question ... I'm using C# winforms on my app. I have 2 combo boxes (id and type) and 1 textbox (name) that are bind to a data that represents an item in a list Changing the 1st combo box (id) - changes the...
26 Aug 2021 by dj4400
I found a solution: The comboBoxType binding should be declared like that: //Clicking the combo box now shows all the enum values comboBoxType.DataSource = Enum.GetValues(typeof(EnumItemType)); //the selected item of the combo box now...
27 Sep 2019 by ScottJohnson13483
I've run into an interesting problem binding a combo box with a Linq query. I'm sure I'm just not hitting on the right combination but it's got me frustrated and chasing my tail. For example, I have a linq query that merely loads an entire table into the query (no where clause) for my flock of...
27 Sep 2019 by ScottJohnson13483
Ok, I finally had some time to mess with it more. You actually pointed me in the right direction by stating that I was making it more complicated than it needed to be. When I set up the databindings, I used the tool provided on the combobox control itself (the little arrow in the upper corner...
25 Mar 2015 by TarikHuber
Use STT (SQL Table Toolkit) to bind WinForm Controls to a DataGridview and to define ComboBox data sources
26 Nov 2013 by Member 9417653
Please under stand the flow of code . I have an interface Ishape which in some separate dll or class library. [InheritedExport] public interface Ishape { int Paint(int width, int height); }In my window application I have two classes. public class...
18 Apr 2014 by Shai Vashdi
Hi,Just use the meta data for example:[ExportMetadata("Name", "ControlsLibrary1.BlueControl")]Then when you load all of the Shapes you can add them to the Combo-Box.You can read more about it in my article:The Simplest Way to use MEF Fully Lazy DLL Loading[^]I hope it...
24 Sep 2012 by jawad59
Issue in binding multiple combobox and datagrid at a time. It just binds the last comobox/datagrid.SetConnection(); sql_con.Open(); sql_cmd = sql_con.CreateCommand(); string CommandText = "SELECT MediaArticle.id,...
24 Sep 2012 by Abhijit Parab
Call Grid.DataBind() method after Grid.DataSource = DT;I hope this is the thing which is missing in your code
8 Nov 2014 by ibrahim_ragab
I have an entity object "Account" that contain fields such thatpublic class Account{ public string Name{get;set;} public int Type{get;set;}}Account Type is a fixed values such that {"basic","derived","no type",...}I bind Name field to text box,I want to bind Type to combo...
8 Nov 2014 by Manas Bhardwaj
Swap the dictionary format. Or I misunderstood the question?Dictionary AccountType = new Dictionary { {0, "no type"}, {1, "basic"}, {2, "derived"} };combo.DataSource = new BindingSource(AccountType, null);combo.DisplayMember =...
29 Nov 2014 by PuchuKing33
Hello everyoneI am new to coding in C#, and i am trying to correctly code in the MVVM pattern using WPF with my MySQL database.I have a form called characters with a combobox called cb_Names. The idea is ones the form is loaded the combobox gets populated with the names of the characters...
1 Apr 2011 by adnama
Im trying to fill up a combobox with the data in a database model of wpf and this is the code im using. of course it is not working but because it is saying that columns it doesn't know what it is. even the word defaultview. please helppublic void bindcombo() { ...
1 Apr 2011 by Eduard Keilholz
I'm not sure about this, but :public void bindcombo(){ LogicLayer.Roles r = new LogicLayer.Roles(); dbmodelDataContext ds = new dbmodelDataContext();@; cmbusertype.ItemsSource = ds.tblRoles.DefaultView; cmbusertype.DisplayMemberPath = "Role"; ...
22 Oct 2014 by SirLearnAlot
Hello Everyone, I made a form (WPF User Control) with a textbox called Tracking_Num, a comboBox called Courier_List, and a button called Tracking_Button. The idea is the user selects a courier, enters the tracking number, and hits track to launch the default browser and track the package using...
20 Oct 2014 by Garth J Lancaster
I presume you've stepped through it with a debugger - put a breakpoint for example in [Tracking_Button_Click] and made sure the button click is going into any of the handlers Are you running under elevation ?There's a discussion here that has a few things that might help - more reading...
22 Oct 2014 by SirLearnAlot
I solved the problem. I changed selectedValue method to selectedIndex, then I changed each option to correspond with index values from 0 - 2.Provided working code, thanks to all who tried to help!private void Tracking_Button_Click(object sender, RoutedEventArgs e) { ...
14 Sep 2011 by Gerry Logrosa
Hi,Good Day!Anyone can help me this combo box problem.I have a combox box that bound a collection objects.bdsItemCode.DataSource = SalesCostItem.GetSalesCostItemByCustVendTypeBranchAndSystemJob(objCurrentCustomerDTO.CustVendTypeCode, objTruckInvoice.BranchCode,...
14 Sep 2011 by SwaxRak
While debugging Check the Count of bdsItemCode and cboItemCode , May be the problem with binding datasource
9 Jan 2019 by Member 13783935
I have two comboboxes which I'm filling with entries in the C# code ComboBoxA.SelectedIndex = 0; ComboBoxA.Items.Add("foo"); ComboBoxA.Items.Add("123"); ...
9 Jan 2019 by TheRealSteveJudge
First of all you must define a list of all possible ComboBox items. Then you must implement event handlers for both ComboBoxes which set the available items according to the selection of the other ComboBox. Please have a look at this example. MainWindow.xaml
9 Jan 2019 by Graeme_Grant
Here is a MVVM solution that disables items in the other Combobox when a selection is made in one... First the Data Binding event plumbing base classes: public abstract class ObservableBase : INotifyPropertyChanged { public void Set(ref TValue field, TValue newValue, ...
11 Oct 2016 by JC Carmo
I am a beginner programmer developing a C# WinForms solution in VS 2015.I was successful in cascading two out of three ComboBoxes. The problem is with the third ComboBox, which doesn't display the correct filtered values. It always displays the same values.Can you please take a look...
11 Oct 2016 by manu_dhobale
This is working code, please have a look.using System;using System.Data;using System.Data.SqlClient;using System.Windows.Forms;namespace WindowsFormsApplication1{ public partial class Form4 : Form { public Form4() { ...
29 Mar 2011 by 3-Sigma
If I have a dropdown style combobox, and I type in a value which isn't in the list but matches the start of a value in the list, then that value gets selected when I click the dropdown arrow. Eg If I type in 13, and 130 is in the list, then 130 is selected if I click the dropwdown arrow. Is...
29 Mar 2011 by Wendelius
Have you tried changing the AutoCompleteMode[^]
20 Nov 2015 by Member 12076824
I am working with comboxbox and facing issue.I have 75 or 50 files listed in comboBox2, when selecetd index reaches 75th or 50th file it throws error.I am trying to change selected index of comboBox1 when selected index reached last file of combobox2.private void...
20 Nov 2015 by Henrik Jonsson
The second if statement does not make any sense, so just remove it. Then you will advance on each click on btnaccept button.
24 Jan 2018 by webbooker
Hello,I have a combobox that is populated via a dataset. That's all fine. I have 'AutoCompleteMode' set to 'SuggestAppend' and 'AutoCompleteSource' set to 'ListItems'. That's all fine and works. The problem is, that the user can still enter any old text he wants. I want the current...
3 Aug 2010 by Peter_in_2780
I don't have the appropriate docco to hand, but there is a style-type property with a name like "DropDownList" which disables typed entry, but still allows "autocomplete" lookup.Good luck,Peter
4 Aug 2010 by Kim Togo
Take a look at ComboBox.TextUpdatePerhaps this can helpComboBox.TextUpdate
2 Jun 2013 by Gerry Logrosa
Hello,Please try this solution. It works in my side.In you combo box1. set these propertiesAutoCompleteMode = SuggestAppendAutoCompleteSource = NoneDropDownStyle = ComboBoxStyle.DropDown;2. Add KeyPress event handle and write thispublic virtual void Cbo_KeyPress(object...
11 Jun 2014 by landy.lan2011
This is another solution, which is implemented based on Gerry Logrosa's solution.1. set these propertiesAutoCompleteMode = SuggestAppendAutoCompleteSource = ListItemsDropDownStyle = ComboBoxStyle.DropDown;2. private void comboBox1_KeyPress(object sender,...
3 Oct 2012 by mcrbne
Hi ; first i am new about c# , Second i have a access database , inside this db i have 2 form , first one Products (productid , productname) and second one ProductData(id, Productid , Model , width , height , price ) , when i select productname , i want to see that selected products model...
3 Oct 2012 by skydger
Try to use DataSource property for your names combobox. kmt = new System.Data.OleDb.OleDbCommand("SELECT ProductID, Productname FROM Products"); kmt.Connection = bag; tablo = new DataTable("Products"); System.Data.OleDb.OleDbDataAdapter oda = new...
24 Jun 2021 by joshrduncan2012
Can anyone help me with how to populate a combobox with data once another combobox has been selected? I'm confused as to how the selectedindexchanged events work. I am using C# with Visual Studio 2010/2012.
10 Sep 2012 by JF2015
Here is some sample code:private void comboBox1_SelectedIndexChanged(object sender, EventArgs e){ comboBox2.Items.Clear(); if (comboBox1.SelectedItem.ToString() == "1") { comboBox2.Items.Add("Hello"); comboBox2.Items.Add("World"); } else { ...
10 Sep 2012 by Prasad_Kulkarni
If you are talking about cascading dropdownlist then have a look:Selecting value in cascading dropdown list dynamically[^]How to populate a dropdown list with another ddl[^]Cascading DropDown - Country to state[^]ASP.NET cascading drop-down-list...
10 Sep 2012 by Mohamed Mitwalli
Hi , Check this private void Form1_Load(object sender, EventArgs e) { DataTable dt = new DataTable(); using (SqlConnection Cn = new SqlConnection(Properties.Settings.Default.con)) { using (SqlCommand Cmd = new SqlCommand("SELECT * FROM ...
10 Sep 2012 by vijay bisht
suppose we have 2 tables one containing records of student and other containing their subjectswe have 2 combo box one for students and other for their subjects'''' giving value to first combobox dataset ds = new dataset() ; string querry = "select studentid,studentname from...
16 Jan 2013 by Dustin Prevatt
I would like to make like 4 comboboxes where each list within the combobox derives from the previous one. I thought this would be as easy as setting each box to a variable and then using that variable in the query for the combobox after it. I have attempted to use a variable in the query editor...
16 Jan 2013 by Abhinav S
I guess what you are looking for is a cascading dropdown set. These links might help you out.http://csharpdotnetfreak.blogspot.com/2012/07/cascading-combobox-in-winforms-windows-forms.html[^]http://sathishnewworld.blogspot.in/2012/07/cascading-combobox-in-winforms-windows.html[^]
16 Jan 2013 by bapu_reddy
Hello Prevatt, This link will help u surely. For this purpose we can use cascading drop downs, these are also so-called dependancy drop downs while loading the consequent drop down it wont effect the entire page i.e, updates only the partial page or specific drop down. Try this code...