I have strange problems with itemindex. On form show I initialize MSelect, where following code is used to set initial value:
- Code: Select all
for i := 0 to MSelect.SelectBoxList[0].Items.Count-1 do begin
if MSelect.SelectBoxList[0].Items[i].Value = cActiveValue then begin
MSelect.SelectBoxList[0].ItemIndex := i+1; // +1: Bug ???
break;
end;
end;
As you can see I have to add +1 on third row because otherwise not right value is shown as selected value.
Example: If there are 3 values in select
A
B
C
then index of value C is 3 instead of 2. And that is of course a problem when I tried to read selected value on form close where code
- Code: Select all
MSelect.SelectBoxList[0].Items[MSelect.SelectBoxList[0].ItemIndex].Value
gives me "Argument out of range value".