Hi i work in visual studio 2015 with c# windows form
i need to assign default value with value 0 and text select to combox
but How can i do that ?
In windows form load i make
- var fileName = string.Format("{0}\\Book3105", Directory.GetCurrentDirectory());
- var connection = string.Format("Provider=Microsoft.ACE.OLEDB.12.0;" + "Data Source={0};Mode=ReadWrite;Extended Properties=Excel 12.0 Xml;", fileName);
- OleDbConnection con = new OleDbConnection(connection);
-
- try
- {
- con.Open();
- str = "select * from [sheet2$]";
- com = new OleDbCommand(str, con);
- oledbda = new OleDbDataAdapter(com);
- ds = new DataSet();
- oledbda.Fill(ds, "[sheet2$]");
- con.Close();
-
- dt = ds.Tables["[sheet2$]"];
- int i = 0;
-
-
- for (i = 0; i <= dt.Rows.Count - 1; i++)
- {
-
- comboBox4.Items.Add(dt.Rows[i].ItemArray[1]);
- }
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message);
- }
I can get data from Excel 2007 xlsx file but cannot assign default value --select-- with selected value 0
How to do that if possible