Show data in multicolumncombobox

2 posts, 0 answers
  1. Tan
    Tan avatar
    5 posts
    Member since:
    Mar 2012

    Posted 25 May 2012 Link to this post


    I have 2 tables in database. strProductID  is primary key in table tblICInventory and strProductID   is reference key in tblICInventoryStockTotal. I want to show strProductID  but it couldn't show data in the Column tblICInventory.strProductID . Please help me !


    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;
                    }
                }
            }
  2. Tan
    Tan avatar
    5 posts
    Member since:
    Mar 2012

    Posted 26 May 2012 Link to this post

    I have resolved this. :D
  3. UI for WinForms is Visual Studio 2017 Ready
Back to Top