12-03-2021, 03:18 PM
(This post was last modified: 12-03-2021, 03:24 PM by MJS@mjs.us.)
(11-29-2021, 03:32 PM)MJS@mjs.us Wrote: C++ Builder 11.0 / IW 15.2.47>>Before even testing it... values shouldn't be the same for different items.
TIWComboBox ItemIndex is not always updated correctly.
For example: TIWComboBox Items populated with
A=1
B=1
C=1
D=2
and ItemsHaveValues = true so that only Names[] values A, B, C, D are visible.
When selecting:
A, ItemIndex == 0 // correct
B, ItemIndex == 0 // incorrect
C, ItemIndex == 0 // incorrect
D, ItemIndex == 3 // correct
The ItemIndex seems to be affected by the Values[] column.
Desired behavior is for ItemIndex to be updated to the true selection offset regardless of the Items content.
Demo attached.
I don't see any requirement for that in the way TStringList or TIWStringList work. IWCombo may be designed that way but's it's a restriction that radically changes the behavior based on ItemsHaveValues=true or ItemsHaveValues=false. I think with ItemsHaveValues=true the IWCombo should display only the Names[] strings, then give the correct ItemIndex when a selection of an item occurs so that the correct Values[] can be returned. Right now an incorrect ItemIndex can be returned (note the property is named ItemIndex not FirstUniqueValueIndex).
>>The value is the KEY of the list and there is no way to distinguish one from
>>the other if you have identical values for two different items.
You don't want to search just the Values[] to determine uniqueness but search for the whole NAME=VALUE string itself (the Item).
>>If you want that 2 different items behave the same in your event handler, you
>>need to treat 1, 2 and 3 the same, not giving first, second and third item the
>>same value "1".
My use case: IWCombBox populated with many 'ACCOUNT_NUM=COUNTYID' strings. COUNTYID can be mostly duplicates but not always. With ItemsHaveValues=true ACCOUNT_NUM displays, COUNTYID does not but I can apply it to the database query based on IWCombBox selection. Seems like a reasonable use case.
>>Imagine a LookupComboBox (from VCL, not IW) where all KeyValues of the list have
>>the same value?
Those are two different components with their own functionality - don't think that's a good comparison. I have a workaround implemented so not waiting on a fix but think this is a design flaw in IWComboBox.

