Board index » delphi » How to set TopIndex of Combo dropdown list?

How to set TopIndex of Combo dropdown list?

My app makes heavy use of several combo-boxes of the csDropDownList
style.
The boxes contain about 100 items, but by far the most commonly chosen
are
Items 0 and 1. DropdownCount is 8.

The problem occurs when the user wants to change such a combobox from
Item 1
to Item 0. The dropdown list appears with Item 1 as the selected and
topmost
item. Item 0 is not visible. Thus the user must scroll the list to bring
Item
0 into view, then click it. This is irritating.

The problem is that, whenever the number of items exceeds the
dropdowncount,
the currently selected item appears at the top of the dropped down
list.  I
would like the currently selected item to appear in the middle of the
dropped
down list.

Does any one know how to do this?

So far I am using the ondropdown event to start a timer, which fires
after the
list has dropped down. Then I try to send a LB_SETTOPINDEX message
to the dropped down list. But this doesnt work for me: perhaps the
dropdown list has a differerent handle to the edit part of the
combo-box.

Thanks for any help
Mark Horridge email: mark.horri...@buseco.monash.edu.au

--
Mark Horridge
Centre of Policy Studies,
Clayton Campus, Monash University,
AUSTRALIA VIC 3168
email mark.horri...@buseco.monash.edu.au

 

Re:How to set TopIndex of Combo dropdown list?


Maybe this is good for you :

procedure TForm1.FormCreate(Sender: TObject);
begin
ComboBox1.ItemIndex:=0;
end;

procedure TForm1.ComboBox1Change(Sender: TObject);
begin
ComboBox1.Items.Move(0,1);
end;

good luck!

Quote
Mark Horridge wrote:
> My app makes heavy use of several combo-boxes of the csDropDownList
> style.
> The boxes contain about 100 items, but by far the most commonly chosen
> are
> Items 0 and 1. DropdownCount is 8.

> The problem occurs when the user wants to change such a combobox from
> Item 1
> to Item 0. The dropdown list appears with Item 1 as the selected and
> topmost
> item. Item 0 is not visible. Thus the user must scroll the list to bring
> Item
> 0 into view, then click it. This is irritating.

> The problem is that, whenever the number of items exceeds the
> dropdowncount,
> the currently selected item appears at the top of the dropped down
> list.  I
> would like the currently selected item to appear in the middle of the
> dropped
> down list.

> Does any one know how to do this?

> So far I am using the ondropdown event to start a timer, which fires
> after the
> list has dropped down. Then I try to send a LB_SETTOPINDEX message
> to the dropped down list. But this doesnt work for me: perhaps the
> dropdown list has a differerent handle to the edit part of the
> combo-box.

> Thanks for any help
> Mark Horridge email: mark.horri...@buseco.monash.edu.au

> --
> Mark Horridge
> Centre of Policy Studies,
> Clayton Campus, Monash University,
> AUSTRALIA VIC 3168
> email mark.horri...@buseco.monash.edu.au

Other Threads