![]() | ![]() Products ![]() ![]() ![]() ![]() |
Home » Technical Support » Elevate Web Builder Technical Support » Support Forums » Elevate Web Builder General » View Thread |
Messages 1 to 10 of 11 total |
![]() |
Wed, Jul 2 2014 6:16 AM | Permanent Link |
Uli Becker | In Delphi I usually use AddObject to add a unique ID to the item of a
combobox - is it possible to do something similar in EWB? What I need is to populate a combobox with string values from a table, but also need the ID of the selected record. Uli |
Wed, Jul 2 2014 7:16 AM | Permanent Link |
Matthew Jones | Uli Becker wrote:
> In Delphi I usually use AddObject to add a unique ID to the item of a > combobox - is it possible to do something similar in EWB? > > What I need is to populate a combobox with string values from a > table, but also need the ID of the selected record. I don't think it is. I keep a separate list in parallel to the combo list, built at run-time, and then I can use the same ItemIndex to do the reference. -- Matthew Jones |
Wed, Jul 2 2014 8:20 AM | Permanent Link |
Uli Becker | Matthew,
> I don't think it is. I keep a separate list in parallel to the combo > list, built at run-time, and then I can use the same ItemIndex to do > the reference. Good workaround - thanks. Uli |
Tue, Dec 16 2014 10:06 AM | Permanent Link |
Petter Topp | "Matthew Jones" wrote:
Uli Becker wrote: > In Delphi I usually use AddObject to add a unique ID to the item of a > combobox - is it possible to do something similar in EWB? > > What I need is to populate a combobox with string values from a > table, but also need the ID of the selected record. I don't think it is. I keep a separate list in parallel to the combo list, built at run-time, and then I can use the same ItemIndex to do the reference. -- Matthew Jones Hi Matthew. Coud you share your solution? Br Petter |
Tue, Dec 16 2014 10:51 AM | Permanent Link |
Uli Becker | Petter,
> Coud you share your solution? I'm not Matthew ![]() IDList := TStringList.create; .... IDList.clear; Comobox1.items.clear; .... MyDataset.first; while not MyDataset.EOF do begin Combobox1.items.add(MyDataset.columns['MyValue'].asString); IDList.add(MyDataset.columns['MyID'].asString); MyDataset.next; end; Chosen value: MyValue := Combobox1.items[ComboBox1.itemindex]; MyIDValue := StrToInt(ComboBox1.itemindex); Hope that helps. Uli |
Tue, Dec 16 2014 11:55 AM | Permanent Link |
Matthew Jones | Uli Becker wrote:
> > I'm not Matthew ![]() > That's the way it's done. Only issue to be aware of is sorting - if you let the combo sort itself, you break your matched lists. Just sort them yourself if needed, or sort them before you add. -- Matthew Jones |
Tue, Dec 16 2014 9:09 PM | Permanent Link |
Stephen Barker | Uli Becker wrote:
MyValue := Combobox1.items[ComboBox1.itemindex]; MyIDValue := StrToInt(ComboBox1.itemindex); -------------------------------------- I think that second line above should read: MyIDValue := StrToInt(IDList[ComboBox1.itemindex]); cheers, Steve |
Wed, Dec 17 2014 1:04 AM | Permanent Link |
Petter Topp | Uli Becker wrote:
Petter, > Coud you share your solution? I'm not Matthew ![]() IDList := TStringList.create; .... IDList.clear; Comobox1.items.clear; .... MyDataset.first; while not MyDataset.EOF do begin Combobox1.items.add(MyDataset.columns['MyValue'].asString); IDList.add(MyDataset.columns['MyID'].asString); MyDataset.next; end; Chosen value: MyValue := Combobox1.items[ComboBox1.itemindex]; MyIDValue := StrToInt(ComboBox1.itemindex); Hope that helps. Uli Thanks Uli - should have solved this my self, I'm getting real lazy... Petter |
Wed, Dec 17 2014 3:45 AM | Permanent Link |
alexza | Given the function:
function RPad(const Value: String; PadLen: Integer; PadChar: Char=' '): String; // from Pad, in Webcore.wbs begin Result := Value; while (Length(Result) < PadLen) do Result := (Result + PadChar); end; another solution, which allows for sorting, is: TempStrings: array of String; .... Combobox1.Items.Clear; MyDataset.First; while not MyDataset.EOF do begin Combobox1.Items.Add(RPad(MyDataset.Columns['MyValue'].AsString, 50, ' ') + '#' + MyDataset.Columns['MyID'].AsString); MyDataset.Next; end; Chosen values: TempStrings := Split(Combobox1.Items[ComboBox1.Itemindex], '#'); // Split, in Webcore.wbs MyValue := Trim(TempStrings[0]); MyIDValue := StrToInt(Trim(TempStrings[1])); The value 50 (length of resulting string so as the combobox shows only the descriptive part and not the IDs) and the separator char '#' can be chosen based on data to be handled. |
Wed, Dec 17 2014 5:38 AM | Permanent Link |
Uli Becker | Stephen,
> I think that second line above should read: > > MyIDValue := StrToInt(IDList[ComboBox1.itemindex]); You are right - that's why I wrote "untested", didn't have much time ![]() Uli |
Page 1 of 2 | Next Page » | |
Jump to Page: 1 2 |
This web page was last updated on Wednesday, November 29, 2023 at 09:43 PM | Privacy Policy![]() © 2023 Elevate Software, Inc. All Rights Reserved Questions or comments ? ![]() |