CGDevTools Forum

Welcome to the Official CGDevTools Support Community Forums.

Issue with ItemIndex - 2

by cyracks » 02 Jan 2019 22:45

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".
cyracks
 
Posts: 92
Joined: 09 Feb 2016 12:47

by cyracks » 02 Jan 2019 22:54

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.
cyracks
 
Posts: 92
Joined: 09 Feb 2016 12:47

by Alexander Bulei » 03 Jan 2019 11:58

Hi cyracks,

ps:I use IW 15.0.18


It's not published version...

Anyway, please send the simple testcase project. TIA

Best Regards.
Group: Developers | Support Team

  • info [at] cgdevtools.com - General information
  • sales [at] cgdevtools.com - Sales department
  • support [at] cgdevtools.com - Product and Technical Support
User avatar
Alexander Bulei
Site Admin
 
Posts: 3635
Joined: 15 May 2012 08:52
Location: Mealhada, Portugal

by cyracks » 03 Jan 2019 12:27

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;
You do not have the required permissions to view the files attached to this post.
cyracks
 
Posts: 92
Joined: 09 Feb 2016 12:47

by Alexander Bulei » 03 Jan 2019 12:31

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.
Group: Developers | Support Team

  • info [at] cgdevtools.com - General information
  • sales [at] cgdevtools.com - Sales department
  • support [at] cgdevtools.com - Product and Technical Support
User avatar
Alexander Bulei
Site Admin
 
Posts: 3635
Joined: 15 May 2012 08:52
Location: Mealhada, Portugal

by cyracks » 03 Jan 2019 12:38

Yes I would also expect value should be set to B, but it is not. Here is a video.
You do not have the required permissions to view the files attached to this post.
cyracks
 
Posts: 92
Joined: 09 Feb 2016 12:47


Return to JQMSelect

cron

Who is online

Users browsing this forum: No registered users and 1 guest

Contact Us.