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);
- }
How to do that if possible
ahmed salahPosted Jan 24, 2017, 10:06 AM
Problem
Selected value to any item in combo box give me null why
Details
I work in windows form c# visual studio 2015
And i get data of combo box from excel sheet 2007
excel sheet have two column
MemberId represent value to combo box
MemberName represent text to combo box
When debug this line under button give me null
and message box show to me when select any item in combo box .
ahmed salahPosted Jan 24, 2017, 9:24 AM
Ali aliPosted Jan 24, 2017, 9:06 AM