Quantcast
Channel: Windows Forms Data Controls and Databinding forum
Viewing all articles
Browse latest Browse all 2535

How to bind the the datatable datasource to a predefined combobox column of the datagridview from the sql

$
0
0

I have  4 column in datagridview, Item, Qty,Rate,Total. I am creating the dropdown list for the columnItem column from the following sql

Select A.Code, A.Description From kmProduct A Where  A.Hidden = 'F'Order ByA.Code

My code is as follows

DataGridViewComboBoxColumn ColProduct = new DataGridViewComboBoxColumn();
            ColProduct.DataPropertyName = "Code";
            ColProduct.HeaderText = "Description";
            kmInvoice objKmInvoice = new kmInvoice();
            DataTable t = new DataTable();
            t = objKmInvoice.GetProductList();
            ColProduct.DataSource = t;
            ColProduct.ValueMember = "Code";
            ColProduct.DisplayMember = "Description";
            dataGridViewInvoice.Columns.Add(ColProduct);

After running the application, it create a new column with the name of Description. How I can create the dropdown  to the existing column 'Item' Please any help very appreciate.

Regards

Pol


polachan


Viewing all articles
Browse latest Browse all 2535

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>