This is a migrated thread and some comments may be shown as answers.

Show data in multicolumncombobox

1 Answer 122 Views
MultiColumn ComboBox
This is a migrated thread and some comments may be shown as answers.
Tan
Top achievements
Rank 1
Tan asked on 26 May 2012, 03:36 AM

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;
                }
            }
        }

1 Answer, 1 is accepted

Sort by
0
Tan
Top achievements
Rank 1
answered on 26 May 2012, 08:49 AM
I have resolved this. :D
Tags
MultiColumn ComboBox
Asked by
Tan
Top achievements
Rank 1
Answers by
Tan
Top achievements
Rank 1
Share this question
or