void AddItemToMultiColumnCombobox()
{
System.Data.OleDb.OleDbConnection con = new System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + System.IO.Path.GetFullPath("../../Database//Demo2.mdb"));
con.Open();
OleDbCommand com = new OleDbCommand("select [tblICInventory].[strProductID] ,memDescription,dblUnitsInStock,dblUnitsAllocated,curSalesPrice,strWarehouseID from tblICInventory,tblICInventoryStockTotal where tblICInventory.strProductID = tblICInventoryStockTotal.strProductID ", con);
OleDbDataAdapter oleda = new OleDbDataAdapter();
oleda.SelectCommand = com;
DataSet ds = new DataSet();
oleda.Fill(ds);
GridViewMultiComboBoxColumn col = new GridViewMultiComboBoxColumn();
col.DataSource = ds.Tables[0].DefaultView;
col.DisplayMember = "tblICInventory.strProductID";
col.ValueMember = "tblICInventory.strProductID";
col.Width = 100;
col.HeaderText = "Item No";
this.radGridViewDetail.Columns.RemoveAt(1);
this.radGridViewDetail.Columns.Insert(1, col);
col.AutoCompleteMode = AutoCompleteMode.None;
col.DropDownStyle = Telerik.WinControls.RadDropDownStyle.DropDown;
this.radGridViewDetail.CellBeginEdit += new GridViewCellCancelEventHandler(radGridViewDetail_CellBeginEdit);
}
bool isColumnAdded;
void radGridViewDetail_CellBeginEdit(object sender, GridViewCellCancelEventArgs e)
{
if (this.radGridViewDetail.CurrentColumn is GridViewMultiComboBoxColumn)
{
if (!isColumnAdded)
{
isColumnAdded = true;
RadMultiColumnComboBoxElement editor = (RadMultiColumnComboBoxElement)this.radGridViewDetail.ActiveEditor;
editor.EditorControl.MasterTemplate.AutoGenerateColumns = false;
editor.EditorControl.Columns.Add(new GridViewTextBoxColumn("tblICInventory.strProductID"));
editor.EditorControl.Columns.Add(new GridViewTextBoxColumn("memDescription"));
editor.EditorControl.Columns.Add(new GridViewTextBoxColumn("dblUnitsInStock"));
editor.EditorControl.Columns.Add(new GridViewTextBoxColumn("dblUnitsAllocated"));
editor.EditorControl.Columns.Add(new GridViewTextBoxColumn("curSalesPrice"));
editor.EditorControl.Columns.Add(new GridViewTextBoxColumn("strWarehouseID"));
editor.EditorControl.Columns[0].HeaderText = "Item No";
editor.EditorControl.Columns[1].HeaderText = "Description";
editor.EditorControl.Columns[2].HeaderText = "Stock";
editor.EditorControl.Columns[3].HeaderText = "Available";
editor.EditorControl.Columns[4].HeaderText = "Price";
editor.EditorControl.Columns[5].HeaderText = "Warehouse";
editor.AutoSizeDropDownToBestFit = true;
}
}
}