How to add an item in combobox before binding data from the database

  • Thread starter Thread starter John6272
  • Start date Start date
J

John6272

Guest
hi, i'm using Metro UI ComboBox in windows application. i just want to add this "Please Select Name" before bind the database. i'm using this code.

public static List<string> GetUserNames()
{
using (SQLiteConnection conn = new SQLiteConnection("Data Source=combolist.db;Version=3;"))
{
string CommandText = "SELECT Id FROM combo ORDER BY Id";
using (SQLiteCommand cmd = new SQLiteCommand(CommandText, conn))
{
conn.Open();
DataTable dt = new DataTable();
SQLiteDataAdapter da = new SQLiteDataAdapter(cmd);
da.Fill(dt);
return dt.Rows.Cast<DataRow>().Select(dr => dr["Id"].ToString()).ToList();
}
}
}


private void fill()
{
comboBox3.SelectedIndex = -1;
comboBox3.DataSource = comboclass.GetUserNames();
}

how to do that combobox show this "Please Select Name" first after that show bind database data.

Continue reading...
 
Back
Top