-
Jul 24th, 2024, 11:38 AM
#1
Thread Starter
New Member
Datagridviewcombobox returns string instead of decimal causing a datagriderror event
I have a datagridview with a combobox column where I set the values of the combobox.items to decimal values. When I select a value I get the dateerror event, and when I look at the value for the combobox column, it is a string, not a decimal, which I guess is what's causing the problem. If I add the values as type string it works. Can I not use a combobox if the values aren't strings?
I tried adding the combobox items as decimals, but that causes the datagridview dataerror.
-
Jul 24th, 2024, 11:42 AM
#2
Re: Datagridviewcombobox returns string instead of decimal causing a datagriderror ev
Maybe... maybe not... how are you adding them to the drop down?
Also, what's the code you're using where the error happens?
-tg
-
Jul 24th, 2024, 12:19 PM
#3
Thread Starter
New Member
Re: Datagridviewcombobox returns string instead of decimal causing a datagriderror ev
cbCol = CType(dgvFoodChoices.Columns("colNumber"), DataGridViewComboBoxColumn)
For Each d As Decimal In Form1.dgvComboBoxItems
cbCol.Items.Add(d.ToString)
Next
If I don't use d.tostring, just d, then when I click on the combobox and select an item, I'll get the datagridview data error. And when I trap that, and look at the value of the combobox, instead of being a decimal, it's a string, which is when I get the fault. Treating the values as strings everywhere fixes the problem, but seem unsatisfactory.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|