DataGridViewComboBoxColumn in DataGridView

0
0

Hi,

I am struggling with the DataGridViewComboBoxColumn in a DataGridView. I am able to populate the ComboBox and add it to the DataGridView, so far so good.

When running the form the ComboBox in the Grid seems to be “invisible”, it is activated only after doubleclick on it (sometimes multiple doubleclicks before something happens). It looks to me as if the ComboBox isn’t initiated yet. I also did not find a way to set e.g. the first Item in the ComboBox.

Unfortunately I cannot find any sample/issue on this subject.

Please advices,

Regards,

Wim

 

  • You must to post comments
0
0

Forgot to add that you can also set the DataGridViewComboBox column in the designer and assign the data source in code. No need to remove and re-add a different column. And you you may use the attached mixin to make all combobox cell display a drop down image mimicking the combobox. See image attached.

Put this in Themes/App.mixin.theme

{
 "appearances": {
 "table-combobox-cell": {
 "inherit": "table-cell",
 "states": {
   "default": {
     "styles": {
       "backgroundImage": "combo-arrow",
       "backgroundSize": "20px",
       "backgroundPosition": [ "center", "right" ]
     }
   }
  }
 }
}
}
Attachment
  • You must to post comments
0
0

Luca, it works, gracias!

  • You must to post comments
0
0

Thank you and sorry I forgot to post a sample. In any case your code works well after you set the DataPropertyName:

cc.DataPropertyName = “Country”

Without that it cannot bind to a data source field.

 

Attachment
  • You must to post comments
0
0

Hi Luca,

Here is an example from what I am trying to achieve….

Regards,

Wim

 

 

Attachment
  • You must to post comments
0
0

The DataGridViewComboBoxCell shows the correct value already. There are no comboboxes created in each cell, it’s not how the DataGridView works. The ComboBox is created in edit mode. If you send a small test case showing the problem it would help.

  • Wim Wetzels
    Than please show me an example how the DataGridView works, because obviously I am walking the wrong path……
  • You must to post comments
0
0

Thanks Luca, I now have a partial solution. The ComboBox is now shown in the DataGridView, that is nice.  But in existing DataGridView records it is still NOT initalized with the field value. Assume we have a DataGridComboBox with Country values and the existing record contains the value “US”, than this not shown in the ComboBoxGridfield.

In the attachment you’ll find the form as created with Visual Webgui. In the various Combo’s as part of the DataGridView all values of existing records are shown.

So the question is: How do I manage that a Combo inside a DataGridView shows the actual value?

I am using VB2015 and cannot find any sample in this respect.

 

Regards,

Wim

 

 

 

  • You must to post comments
0
0
  • You must to post comments
Showing 7 results
Your Answer

Please first to submit.