Click here to Skip to main content
15,905,028 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I have a combobox and it has a item collection. this combo box's dropdownstyle is (DropDownList)

i want to load one of item in a item collection list by pressing a button
how to do this..?
Posted
Comments
Expert Coming 4-Dec-12 1:39am    
What do you mean load an item? You want to add another item?

 
Share this answer
 
hi dear,

I don't understand. what you want ? I give some information. Please observe it.

private void FxComboBox()
        {
            SqlConnection objConn1 = new SqlConnection("Data Source= Sql Server Name ;Initial Catalog= Database Name ;user id=sa; password=123;"); // Write you sql server database name and necessary option.       
            string SQL = "Select * From TableName";
            SqlCommand cmd = new SqlCommand(SQL, objConn1);            
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            DataTable dt = new DataTable();
            da.Fill(dt);
            if (dt.Rows.Count > 0)
            {
                comboBox1.DataSource = dt;
                comboBox1.DisplayMember = "ColoumName" ;
                comboBox1.ValueMember = "ColoumName" ;
                comboBox1.DropDownStyle = ComboBoxStyle.DropDownList;
            }
        }
 
Share this answer
 
Comments
Orcun Iyigun 4-Dec-12 2:57am    
If you dont understand his question why do you answer his question in the first place??
azizulhoque.bd 4-Dec-12 3:02am    
I am just try.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900