Page 1 of 1

Issue with ItemIndex - 2

PostPosted: 02 Jan 2019 22:45
by cyracks
Hello,

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".

Re: Issue with ItemIndex - 2

PostPosted: 02 Jan 2019 22:54
by cyracks
I found out that the problem is in placeholder. If Placeholder is disabled then it works as expected.

ps:I use IW 15.0.18 and CGDevTools: 15.0.17.

Re: Issue with ItemIndex - 2

PostPosted: 03 Jan 2019 11:58
by Alexander Bulei
Hi cyracks,

ps:I use IW 15.0.18


It's not published version...

Anyway, please send the simple testcase project. TIA

Best Regards.

Re: Issue with ItemIndex - 2

PostPosted: 03 Jan 2019 12:27
by cyracks
I know but it is the only version that works with Rio 10.3 and I think IW15 is preferred version by Atozed.

Code: Select all
procedure TIWAppForm2.IWAppFormShow(Sender: TObject);
begin
    IWCGJQMSelect1.SelectBoxList[0].Items.AddOption('A', 'A');
    IWCGJQMSelect1.SelectBoxList[0].Items.AddOption('B', 'B');
    IWCGJQMSelect1.SelectBoxList[0].Items.AddOption('C', 'C');

    IWCGJQMSelect1.SelectBoxList[0].ItemIndex := 1; // SET VALUE TO A

end;

procedure TIWAppForm2.IWCGJQMButton1JQMButtonOptionsEventsVClick(Sender: TObject; AParams: TStringList);
begin
    with IWCGJQMSelect1.SelectBoxList[0] do begin
        WebApplication.ShowMessage(Items[ItemIndex].Value); // SHOW VALUE B
    end;

end;

Re: Issue with ItemIndex - 2

PostPosted: 03 Jan 2019 12:31
by Alexander Bulei
Hi cyracks,

IWCGJQMSelect1.SelectBoxList[0].ItemIndex := 1; // SET VALUE TO A


I don't understand your problem...the itemIndex start from 0, so it will set the value to B.

Best Regards.

Re: Issue with ItemIndex - 2

PostPosted: 03 Jan 2019 12:38
by cyracks
Yes I would also expect value should be set to B, but it is not. Here is a video.