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

Datagridviewcombobox

$
0
0

I have a datagridviewcombobox which gets loaded with a display text and value .... I need the combobox to connect to that rows data in the datagridview, so I made the datapropertyname = to the collumn in the datagridview. The problem is that it's loading and giving me the error: "THE FOLLWOING EXCEPTION OCCURED IN THE DATAGRIDVIEW: SYSTEM.FORMATEXCEPTION: DATAGRIDVIEWCOMBOBOXCELL VALUE IS NOT VALID. TO REPLACE THIS DEFAULT DIALOG PLEASE HANDLE THE DATAERROR EVENT", and then it's loading the combobox items with the proper items but the display of the cell is the value member (the actual value in the table that the datagridview is joined by.) Why is that so? It should really be loading each combobox cell with the corresponding displaymember of the valuemember that it's joined to.

Here is the way the datagridview and datagridviewcombobox is getting loaded:

     Data.GetDataForDataSet("WorkOrders_Select", dsInvoicingFilter);//this loads the table which the datagridview gets bound to.

                   DataGridViewBinding.BindWithData(true, dsInvoicingFilter.Tables[0], dgvInvoices, lblEntryCount, bs);//this loads the datagridview.

                   DataTable dt = newDataTable();

                    Data.GetData("Employees_Select", dt);

                   DataGridViewComboBoxColumn cmbColumn = newDataGridViewComboBoxColumn();

                    cmbColumn.Name ="PickedBy";

                    cmbColumn.HeaderText ="Picked By";

                    cmbColumn.FlatStyle =FlatStyle.Flat;

                    cmbColumn.DataSource = dt;

                    cmbColumn.DataPropertyName ="EmployeeID";//this is the column in the datagridview's table that the combobox should get bound to.

                    cmbColumn.ValueMember ="EmployeeID";

                    cmbColumn.DisplayMember ="Name";

                    dgvInvoices.Columns.Add(cmbColumn);


Debra has a question


Viewing all articles
Browse latest Browse all 2535

Trending Articles



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