1
Reply

Add new Row into comboBox in Windows Form

Bineesh  VP

Bineesh VP

Oct 5 2013 6:54 AM
1.1k
Sir, I need your help in solving a doubt in Windows Form Application.

Please go through the code below. Data is being rendering from database.

I want to insert "-Select-" to the Zero index of the comboBox.

How can it possible?

try
{
if(sqlCon.State==ConnectionState.Closed)
{
sqlCon.Open()
}
DataTable dtbl=new DataTable();
SqlDataAdapter Sqlda=new SqlDataAdapter("StudentViewAll", sqlCon);
da.Fill(d);
combBox1.DataSource = dtbl;
comboBox1.DisplayMember="Name";
comboBox1.ValueMember="id;
}
catch(Exception)
{
throw;
}

Answers (1)