[Lazarus] About TComboBox.Items.IndexOfName

Antonio Fortuny a.fortuny at sitasoftware.lu
Thu Oct 31 08:56:49 CET 2013


Le 30/10/2013 22:41, FreeMan a écrit :
> Hello,
> I'm not sure is this bug? can some one test please? and if its but 
> I'll make new issue.
> I have a TComboBox, I add 2 strings. I wanna do, if TmpStr is in the 
> items, do it selected.
>
>   I := EDT_User.Items.IndexOfName(TmpStr);
>   EDT_User.ItemIndex:= I;
>
> 1-) I is always return -1;
Well, I don't know what's in the Items property (TStrings) but if I 
execute a
Index := Combo.Iyems.IndexOf('My text');

I receive 7 when the string 'My text' is in the 8th position, counting 
from 1.
When the Items property contains
one=1
two=2
three=3
four=4
doing:
   str := 'three';
   Index := ComboBox1.Items.IndexOfName(str);
   str2 := ComboBox1.Items.Values[str];
   MessageDlg('Search',Format('index:%d, val:%s', [Index, str2]), 
mtInformation, [mbOK], 0, mbOK);
result is 'index:2 val:3

platform is Vista32, Lazarus 1.0.12

Antonio.

> 2-) I add breakpoint on IndexOfName function, debugger stop there, 
> when click F7 not to go that function, I added breakpoint in 
> IndexOfName function, but never stop in, directly jump to next line on 
> my code.
> 3-) EDT_User.ItemIndex:= 1; this code not to trigger Text property, 
> text not change
>
> /opt/freepascal/2.7.1/rtl/objpas/classes/stringl.inc    line 784
>
> Kubuntu 13.10 x64
> fpc svn update 25886
> lazarus svn update 43343
> QT
>
> -- 
> _______________________________________________
> Lazarus mailing list
> Lazarus at lists.lazarus.freepascal.org
> http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
>







More information about the Lazarus mailing list