Login ProductsSalesSupportDownloadsAbout |
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 |
Christian Kaufmann | Hi,
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; begin if (ItemIndex <> -1) then Result := GetKeys(ItemIndex) else Result := 0; end; procedure TBSCustomComboBox.SetFocusedKey(AValue: Integer); var ix : Integer; begin for ix := 0 to Items.Count - 1 do if (GetKeys(ix) = AValue) then begin ItemIndex := ix; Exit; end; ItemIndex := -1; CheckMandatory; end; function TBSCustomComboBox.GetKeys(AIndex: Cardinal): Integer; begin Result := Integer(Items.Objects[AIndex]); end; 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 id's. 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. cu Christian |
Mon, Jun 17 2013 8:44 AM | Permanent Link |
Matthew Jones | Christian,
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. /Matthew Jones/ |
Mon, Jun 17 2013 9:46 AM | Permanent Link |
Christian Kaufmann | >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: sctClub sctRegion sctInterregion sctNation 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. cu Christian |
Mon, Jun 17 2013 9:56 AM | Permanent Link |
Matthew Jones | 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! /Matthew Jones/ |
Tue, Jun 18 2013 1:49 AM | Permanent Link |
Christian Kaufmann | >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. cu Christian |
This web page was last updated on Friday, November 1, 2024 at 07:01 PM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |