tags:

views:

25

answers:

2

hi all i want to make a 2 comboBoxes ,the first one shows Hours and the Second Shows minutes but i cant do so in windows application as i have working as a web dev for a while and i forgot so i want to declare listItems then bind it to combo box i want to make it as a custom control

so i want some help to tell me how to do that

i am using VS 2008 thnxx

+1  A: 

Not sure if this is what you want; see ComboBox class, to add items to combo box programmatically.

Assuming that you have two combo boxes for hours(cbxHours) and minutes(cbxMinutes), you can call SetHours(), and SetMinutes() to populate your combos.

void SetHours()
{ 
   for (int i = 0; i < 2400; i+=100) {cbxHours.Items.Add(string.Format("{0:0###}", i));}
}

void SetMinutes()
{
   for (int i = 0; i < 60; i++) { cbxMinutes.Items.Add(string.Format("{0:0#}", i)); }
}
KMan
there is no comboBox1.Items
hatem gamil
@Hatem: Did you check the link that I provided? It contains the example of `.Items.Add`? Please see my updated answer.
KMan
A: 

you can do it simply by the following code :

comboBox1.DataSource= Enumerable.Range(1, 12).ToList();
comboBox2.DataSource = Enumerable.Range(1, 60).ToList();
Space Cracker