Board index » delphi » WINDOWS GURUS: Please help with a Delphi problem...

WINDOWS GURUS: Please help with a Delphi problem...

Nasir,
  If you want to select a item by it's index number then use:

begin
  DBListBox1.ItemIndex := 2;
end;

To set it so nothing is highlighted do something like:

begin
  DBListBox1.ItemIndex := -1;
end;

If you want to highlight/select an item by it's content (e.g. an item named
"Item4") then do something like:

begin
  DBListBox1.ItemIndex := DBListBox1.Items.IndexOf('Item4');
end;

To set it so nothing is highlighted using the same code do something like:

begin
  DBListBox1.ItemIndex := DBListBox1.Items.IndexOf('');
end;

Hope this helps!
--
Rod Geraghty (:>)
GERA-Tech
Ottawa, Canada
gera...@ibm.net

NNOOR <Nn...@cris.com> wrote in article
<5km3d2$...@chronicle.concentric.net>...

Quote

> VCL Object TDBLookupListBox (a data aware version of a regular ListBox)
> is when initially displayed, it does not have any item high lighted.
> There isn't any obvious way to high light an item at will or take the
> high light away (this is more important). Any help would be greatly
> appreciated. Thanks.

> regards,
> --nasir (nn...@cris.com)

 

Re:WINDOWS GURUS: Please help with a Delphi problem...


VCL Object TDBLookupListBox (a data aware version of a regular ListBox)
is when initially displayed, it does not have any item high lighted.
There isn't any obvious way to high light an item at will or take the
high light away (this is more important). Any help would be greatly
appreciated. Thanks.

regards,
--nasir (nn...@cris.com)

Re:WINDOWS GURUS: Please help with a Delphi problem...


Additional information to the follow-up, add the following codes in
your OnEnter event:

procedure TForm1.DBListBox1Enter(Sender: TObject);
begin
        //      This would highlight the first item when no item is highlighted.
        if(DBListBox1.Items.Count>0)and(DBListBox1.ItemIndex=-1) then
                DBListBox1.ItemIndex:=0;
end;

Quote
>Nasir,
>  If you want to select a item by it's index number then use:

>begin
>  DBListBox1.ItemIndex := 2;
>end;

>To set it so nothing is highlighted do something like:

>begin
>  DBListBox1.ItemIndex := -1;
>end;

>If you want to highlight/select an item by it's content (e.g. an item named
>"Item4") then do something like:

>begin
>  DBListBox1.ItemIndex := DBListBox1.Items.IndexOf('Item4');
>end;

>To set it so nothing is highlighted using the same code do something like:

>begin
>  DBListBox1.ItemIndex := DBListBox1.Items.IndexOf('');
>end;

>Hope this helps!
>--
>Rod Geraghty (:>)
>GERA-Tech
>Ottawa, Canada
>gera...@ibm.net

>NNOOR <Nn...@cris.com> wrote in article
><5km3d2$...@chronicle.concentric.net>...

>> VCL Object TDBLookupListBox (a data aware version of a regular ListBox)
>> is when initially displayed, it does not have any item high lighted.
>> There isn't any obvious way to high light an item at will or take the
>> high light away (this is more important). Any help would be greatly
>> appreciated. Thanks.

>> regards,
>> --nasir (nn...@cris.com)

Re:WINDOWS GURUS: Please help with a Delphi problem...


Thanks for all your help *BUT* my question was for a dbLOOKUPlistBox
and not a dbLISTbox.

Does anyone know how to do it with dbLOOKUPlistBox?

regards,
--nasir (nn...@cris.com)

Re:WINDOWS GURUS: Please help with a Delphi problem...


Sorry for I just read the follow-up.  May be you need this:

//      1 is the value of first item
DBLookupListBox1.KeyValue:=1;

Alsan

Quote

>Thanks for all your help *BUT* my question was for a dbLOOKUPlistBox
>and not a dbLISTbox.

>Does anyone know how to do it with dbLOOKUPlistBox?

>regards,
>--nasir (nn...@cris.com)

Other Threads