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

How to add a GridViewComboBoxColumn to my datagrid

$
0
0

I'm new to C# and visual programming.  This is a WINFORM application and I'm stuck.  Help greatly appreciated.

I want to add a DataGridViewComboBoxColumn or a listbox to my 'dgvColumns' grid on column 'DataDomain'.  The list is only 9 items (RAW, PKIEN, VARCHAR, FileMan, Computed, SetOfCodes, FMDate, FMDateTime,MCode).  I found a tutorial and have added the combo box but have problems.

1)  The major issue is the underlying table isn't updating. 

2)  Minor issue: I have to click the drop down arrow twice to see the list.  Any ideas how to fix this. 

3)   Minor issue but very annoying:  when I add a combo box it changes the order columns are displayed in DatagGridView.  Places as last column. 

The article CoolDad referenced mentioned setting DataPropertyName to column in table.  Could this be the problem?  How do you do this?

"MSDN:  If the DataGridView is bound to a database table, set the columnDataPropertyName property to the name of a column in the table."

My code that binds datagridview to datasource and creates combo box.

private void getChildNodesToGrid()
        {
            DataTable dt1 = getFieldsTable();
            dgvColumns.DataSource = dt1;

            DataGridViewComboBoxColumn DataDomain = new DataGridViewComboBoxColumn();
            DataDomain.HeaderText = "DataDomain";
            DataDomain.Name = "combo";
            ArrayList drl = new ArrayList();
            drl.Add("fmDate");
            drl.Add("fmDateTime");
            drl.Add("Raw");
            drl.Add("Raw");
            DataDomain.Items.AddRange(drl.ToArray());
            dgvColumns.Columns.Add(DataDomain);
            //end combo box add


            getAttributeSIDs();
        }




Viewing all articles
Browse latest Browse all 2535

Trending Articles



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