as described in the title i’m unable to populate datasource of DataGridViewComboBoxCell.
No items are displayed, seems that datasource is not send to the client or not load.
I attach a little sample (WisejDGV.zip).
Can somebody helps ?
Visual Studio 15.8.7
Seems the problem is related to a UserControl. If I use the same logic on a Window there is no problem.
I attach the sample updated (WisejDGV2.zip).
See attached fixed app. It shows the problem and the fix in Wisej and WinForms.
The problem is that when you assign the data source in the Load event you can’t use the rows right away when it’s in a user control. The same happens in WinForms (your sample doesn’t work in winforms as well). The DGV data binding implementation may populate the rows several times depending on the binding context changed event. You should use the DataBindingComplete event.
The same happens if you change colors right after assigning the data source in a child of a child. When the binding context changes the rows are recreated and your changes are lost. If you use the DataBindingComplete event it works well.
yes it’s correct your suggestion, but what i posted is a sample from my working project where I need to set different DataSource for DataGridViewComboBox on every line. That’s why the sample is setting it on every line. In my working project i have no problem doing that on a Window with DataGridViewComboBox, but using a UserControl no datasource is set.
Thanks for any further suggestion.
Note that also trying to set background color for row, no color is set. Seems that the DataGridView in the UserControl is not updating.
I attach the sample updated (WisejDGV3.zip).
When using a ComboBox column in a DGV, the ComboBox data source should be specified just once. Your original project was specifying the ComboBox data source on every row.
Please find attached your project fixed and converted to WinForms.
There is a DataBinding example in GitHub but it doesn’t show an example of a ComboBox column. It will be updated.
Please login first to submit.