0
Thanks for the replay this is very use full tip,
but I have to give the ValueMember as "client_id" because I am saving the combobox selected value, means just saving the "client_id" to the database
0
If you want to use a standard ComboBox rather than the custom one which Pritish appears to be using, then you'll need to create a List<string> where each item in the List combines the two fields you want to use for a particular row. Something like the following if the ID is always of a constant width:
List<string> list = new List<string>();
foreach(DataRow row in dt.Rows)
{
list.Add(String.Format("{0} {1}", row["client_id"], row["client_name"]);
}
comboName.DataSource = list;
// no need to set DisplayMember and ValueMember properties
To get the columns to line up properly, you'll also need to use a fixed-width font such as Consolas.
0
protected override void OnDropDown(System.EventArgs e){
Form parent = this.FindForm();
if(this.dataTable != null || this.dataRows!= null){
MultiColumnComboPopup popup = new
MultiColumnComboPopup(this.dataTable,
ref this.selectedRow,columnsToDisplay);
popup.AfterRowSelectEvent+=
new AfterRowSelectEventHandler
(MultiColumnComboBox_AfterSelectEvent);
popup.Location = new Point(parent.Left +
this.Left + 4 ,parent.Top +
this.Bottom + this.Height);
popup.Show();
=====
multiColumnComboBox1.Table = dtable;//DataTable
//Column to display after selection
multiColumnComboBox1.DisplayMember = "Band";
multiColumnComboBox1.ColumnsToDisplay = new
string[]{"Band","Song","Album"};//columns to display
//in the dropdown grid