|Home » Technical Support » Elevate Web Builder Technical Support » Support Forums » Elevate Web Builder General » View Thread|
|Messages 1 to 5 of 5 total|
|TComboBox - selected item|
|Mon, Jun 17 2013 3:53 AM||Permanent Link|
Using TCombobox to select an item from a list works fine. However I
can only get the ItemIndex.
I had the same problem in Delphi and there I added a property
"FocusedKey : Integer". The implementation looks like this:
function TBSCustomComboBox.GetFocusedKey: Integer;
if (ItemIndex <> -1)
then Result := GetKeys(ItemIndex)
else Result := 0;
procedure TBSCustomComboBox.SetFocusedKey(AValue: Integer);
ix : Integer;
for ix := 0 to Items.Count - 1 do
if (GetKeys(ix) = AValue) then begin
ItemIndex := ix;
ItemIndex := -1;
function TBSCustomComboBox.GetKeys(AIndex: Cardinal): Integer;
Result := Integer(Items.Objects[AIndex]);
Basically I used the Objects property of the Items to save any key for
a certain item. Like this I could resort items (e.g. depending on
language) but the selected id (FocusKey) is always the same. It's also
usefull, if the Items sometimes have a subset only or if you add a new
item, that should apear on the top but you don't want to change all
I know the OPTION element in SELECT has a value property in HTML. But
I have no idea, how I could implement that in EWB right now.
|Mon, Jun 17 2013 8:44 AM||Permanent Link|
What is the problem you are actually trying to solve here? It looks like you are
wanting to link a combo box text to a particular value yes? I just use a separate
list in the form, and keep them in sync.
|Mon, Jun 17 2013 9:46 AM||Permanent Link|
>What is the problem you are actually trying to solve here? It looks like you are
>wanting to link a combo box text to a particular value yes? I just use a separate
>list in the form, and keep them in sync.
Sure I could do that, but I use this in different places again and
again. Here an example:
I start with a type in Delphi:
TBSSwClubType = (sctClub, sctRegion, sctNation)
First, everything is fine. I can map directly to the ItemIndex. Now I
add a new type:
TBSSwClubType = (sctClub, sctRegion, sctNation, sctInterRegion);
I do this at the end, because I mapped the values to a database
integer field as well. But for the Combobox I want a different order:
Therefor I created this FocusedKey property to use the TCombobox with
a list of items, where the Key <> ItemIndex.
I did that ten years ago. Couldn't live without it in Delphi.
|Mon, Jun 17 2013 9:56 AM||Permanent Link|
I don't know if the combo does the Data or Item property, but one way would be to
create a class that you use to link things up. So you'd create a form member of
MyLink : TComboLink and use
MyLink := TComboLink.Create(comboClubType) to associate things. Not ideal, but
saves repeating things. And it works back in Delphi land too.
Just a suggestion!
|Tue, Jun 18 2013 1:49 AM||Permanent Link|
>I don't know if the combo does the Data or Item property, but one way would be to
>create a class that you use to link things up. So you'd create a form member of
That's what I plan to do. I already have my own base class for forms
and I plan to play around with doing that for TCombobox. Not 100%
sure, if the IDE will be able to deal with it, but since it will be
only runtime properties, it may work.