[Lazarus] Problem with ComboBox

Paul Parkyn zl3app at paradise.net.nz
Thu Sep 2 00:01:26 CEST 2010


On Wed, 2010-09-01 at 19:47 +0200, John vd Waeter wrote:
> It is a string, so decimal separator is not involved. I think setting 
> the text  likely invokes textsearch, like when typing, and then the 
> first occurance matching '11' is '11.2'.
> 
> See what happens if you place '11' before '11.2'
> 
> john
> 
> 
> faber wrote:
> > 2010/9/1 ik <idokan at gmail.com>:
> >> Try to do something like
> >>
> >> ComboBox1.ItemIndex := 1;
> >>
> > 
> > Yes, in my case I must use loop:
> >         for i:=0 to ComBoBox1.Items.Count-1 do
> >            if faVar = strtofloat(ComboBox1.Items[i]) then begin
> >               ComboBox1.ItemIndex:=i;
> >               break;
> >            end;
> > 
> > however ComboBox.Text:='11' should work if '11' is in ComboBox1.Items,
> > when I replace '11.2' with '22' then it works,
> > obviously the problem is with a decimal separator, so I thought it's a bug.
> > 
> > best regards
> > faber
> > 
> > --
have you tried something like this:-

     If ComboBox1.Items.IndexOf(FloatToStr(faVar)) <> -1 then
     begin
       ComboBox1.ItemIndex:=ComboBox1.Items.IndexOf(FloatToStr(faVar));
       Label1.Caption:=Msg + IntToStr(ComboBox1.ItemIndex);
     end;





More information about the Lazarus mailing list