I tried in vain to see what you are experiencing but could not reproduce any
errors. Here is what I have so far:
Dim cb As New Windows.Forms.DataGridViewCheckBoxCell
Dim cs As New DataGridViewCellStyle
cs.NullValue = False
cb.Style = cs
Me.DataGridView1.Columns.Add(New DataGridViewColumn(cb))
'Me.DataGridView1.Rows.Add(5)
Gday Rajneesh,
Ok, Im a fair way down the development track so it's hard to isolate
precisely what's going on...
Basically the datagridview that I have has been working correctly for
quite a while (datagridview contains both dropdowns and checkboxes)
and these were working fine...
However, in trying to address the problem with the dropdowns inside
the datagridview where a user has to click on them twice for them to
drop down - my aim is to change this so that users only have to click
once for them to drop down. One way that seemed to work was to change
the EditMode of the datagridview to be 'EditOnEnter' (instead of the
default 'EditOnKeyStrokeOrF2'.)
This allowed the dropdowns to work with a single click, however it
stopped the checkboxes from working and resulted in dataerrors in the
gridview...
Here is my code for where I add the combo and checkbox columns:
-------------------------------------------------------
// set datasource
dgv.DataSource = myDataSet;
dgv.DataMember = <myTable>;
// create dataview for our combo box
DataView myDataView = new
DataView(myDataSet.<lookup_table>);
myDataView.RowFilter = "<lookup_table.field>=<filter
criteria>";
// create a new combo box item
DataGridViewComboBoxColumn dgvCbo = new
DataGridViewComboBoxColumn();
dgvCbo.DataPropertyName = <dpname>;
dgvCbo.DataSource = myDataView;
dgvCbo.DisplayMember = <myDataView.field>;
dgvCbo.ValueMember = <myDataView.field>;
dgvCbo.Name = "myCombo";
dgvCbo.HeaderText = "Combo Box Field";
dgvCbo.Width = 80;
dgv.Columns.Add(dgvCbo);
// set the checkbox column
DataGridViewCheckBoxColumn dgvChk = new
DataGridViewCheckBoxColumn();
dgvChk.Name = "myCheckBox";
dgvChk.HeaderText = "Check Box Field";
dgvChk.Width = 60;
dgv.Columns.Add(dgvChk);
-------------------------------------------------------
As I said, it was all working fine until I changed the datagridview's
editMode to be 'EditOnEnter'.
Any ideas/suggestions would be welcome. Maybe I am too far down the
dev track and just need to scrap this datagridview and start again.
Regards,
Peter