Krypton-Suite / Standard-Toolkit

An update to Component factory's krypton toolkit to support .NET Framework 4.6.2 - 4.8.1 to .NET 6 - 8
BSD 3-Clause "New" or "Revised" License
376 stars 56 forks source link

[Bug]: KryptonDataGridViewComboBoxColumn Ignores ValueMember in Binding #1241

Open cuppm opened 7 months ago

cuppm commented 7 months ago

Describe the bug The KryptonDataGridViewComboBoxColumn appears to ignore the property you specify in the DataSource object to use as the ValueMember. When parsing the value to send to the data bound property it sends the value of the DisplayMember. If you change the DisplayMember to be the ValueMember, it displays the wrong item in the dropdown control but will successfully save the selected item's value to the DataGridView's row item.

Here is a simple example that shows the behavior. Program.cs.txt

To Reproduce Steps to reproduce the behavior:

  1. Build and run the attached simple app
  2. Click "Yes" button to run as Krypton version
  3. Create a new row by entering a test value in Name column. When you leave the cell it will display the value that was attempted to be parsed and set to the data bound object for the row in the top textbox at the bottom. Note that the Option column displays the string value of Guid.Empty instead of the expected "Blank" image
  4. Open the dropdown for the first row and select "Option 2", then leave the cell to force the parsing image
  5. The bottom textbox at the bottom shows the exception message thrown by the datagrid and the top shows the value it tried to parse was the "Option 2" instead of the guid value for that option. image

Expected behavior If you run the simple app and select the "No" button at startup to run the WinForms version, it will correctly bind to the ValueMember of the combobox DataSource.

Correctly displaying the Guid.Empty display value of "Blank": image

Successful parsing of Option 2: image

Screenshots inlined above

Desktop (please complete the following information):

Additional context

DarthVader85PA commented 7 months ago

Hey @cuppm

I had the same problem. My workaround: I changed the column in the KryptonDataGridView to DataGridViewComboBoxColumn and did NOT use the KryptonDataGridViewComboBoxColumn. For the design I used the FlatStyle-property by setting it to "Flat".

grafik

Merry X-Mas from Germany

cuppm commented 7 months ago

@DarthVader85PA Vielen Dank! That'll do as a work around for now. FlatStyle = Flat makes it much cleaner, can't say I've ever messed with that property before.