1

I have a datagridview that is bound to a dataset via a table adaptor which in turn linked to a SQL table.

enter image description here

I want to change the cell type of the status and priority columns to comboboxes.

I have tried this:

 private void dgvFechas_ColumnAdded(object sender, DataGridViewColumnEventArgs e)
    {
        try
        {
            if (e.Column.ValueType == typeof(TextBox) && (e.Column.Index == 5) || (e.Column.Index == 6))
            {
                e.Column.CellTemplate = new DataGridViewComboBoxCell();
            }
        }
        catch (Exception ex) { }
    }

but it doesnt seem like the event handler fires when the program starts up.

So im not too sure how i can get it to work.

James Morrish
  • 455
  • 6
  • 24
  • @JohnG, I guess really the columns are never added becuase the columns are synced to the datatable witch is synced to the SQL database. There should be no vaules “Priority” and “Status” columns until a user set one via a combobox. – James Morrish Feb 18 '19 at 09:56

1 Answers1

0

I followed this guide which allowed me change the cell type:

https://social.msdn.microsoft.com/Forums/windows/en-US/c6d60712-135e-4fd3-a6a0-51dbb4be0dca/how-to-add-combobox-to-winform-datagridview-bound-to-datatable?forum=winforms

After doing this i got a data_error which i fixed by ignoring the data error event. I know that isnt really the correct way of doing things, but it works for me.

 private void dataGridView1_DataError(object sender, DataGridViewDataErrorEventArgs e)
    {
        //ignore
    }
James Morrish
  • 455
  • 6
  • 24