|
|
![]() |
| Thread Tools | Search this Thread |
#1
| |||
| |||
How to set combobox dictionary entry with correct value In my project I wanted populate a ComboBox in WinForms with which input the value of pair objects, WebForms. The only problem is that the ComboBox doesn't seem to know how to use the objects properly. When i was studying about ComboBox in WinForms i heard that it only supports one piece of data, this data is shown and returned as the value. I have seen certain value and have an underlying value which is then returned to the SelectedValue property.Does anyone know how to give the ComboBox the right value, or does anyone know a way to get a name-value type ComboBox WebForms? |
#2
| |||
| |||
Re: How to set combobox dictionary entry with correct value You may use the following programming logic to develop an application according to your requirement. Code: public static void FillBox(System.Windows.Forms.ComboBox cmb, Dictionary<int,ProjectInfo> projects) { // grab a List<> from a Dictionary<> List<ProjectInfo> lst = new List<ProjectInfo>(projects.Values); // create an initial item lst.Insert(0, new ProjectInfo(0, "<PROJECTS>")); cmb.DataSource = lst; cmb.ValMember = "ProjectID"; cmb.DisMember = "ProjectName"; } |
#3
| |||
| |||
Re: How to set combobox dictionary entry with correct value I have also used the similar kind of coding to my project, here I think that second parameter the name of the property (of the first parameter) that what you want to bind to for exa. Code: lst.Insert(0, new ProjectInfo(0, "<PROJECTS>")); |
#4
| |||
| |||
Re: How to set combobox dictionary entry with correct value You may also be used to Probably doesn't recognize the value property of the dictionaryentry as a column. Use: Code: gDelimiter = DirectCast(cboDelimiter.selecteditem, DictionaryEntry).value |
![]() |
|
Tags: combobox, dictionary entry, property value, webforms |
Thread Tools | Search this Thread |
|
![]() | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Need Help With ComboBox | Reyas | Software Development | 1 | 29-04-2012 12:53 PM |
Use of combobox in script | Martien | Software Development | 3 | 15-01-2010 11:58 AM |
Combobox and Text value | HarshaB | Software Development | 5 | 09-11-2009 07:16 PM |
How to lock combobox | JamesB | Software Development | 3 | 19-03-2009 07:20 PM |
Add ComboBox in DataGrid in VB 6.0 | Jateen | Software Development | 3 | 15-01-2009 06:31 PM |