![]() | ![]() Products ![]() ![]() ![]() ![]() |
Home » Technical Support » Elevate Web Builder Technical Support » Support Forums » Elevate Web Builder General » View Thread |
Messages 1 to 6 of 6 total |
![]() |
Wed, Jul 15 2015 12:06 PM | Permanent Link |
Trinione | Hi:
How can a value be associated with the ListBox item? In Pascal I can do the following: ListBox1.AddItem('Item 1', TObject(111)); ShowMessage(IntToStr(Integer(ListBox1.Items.Objects[ListBox1.Items.IndexOf('Item 1')]))); This doesn't work in EWB2. |
Wed, Jul 15 2015 12:59 PM | Permanent Link |
Uli Becker | That's not possible, at least for now.
You can create a second stringlist that holds the desired values with matching indexes. Uli |
Thu, Jul 16 2015 1:40 PM | Permanent Link |
Trinione | Thank you.
|
Thu, Jul 16 2015 6:21 PM | Permanent Link |
Steve Gill | Hi Trinione,
I use a TStringList to get around this. When I add the values to the Listbox, I also add them to the StringList. ListBox1.AddItem('Item 1'); StringList1.Values['Item 1'] := IntToStr(111); Then when the value is selected in the ListBox, I read the corresponding value from the StringList. ShowMessage(StringList1.Values[ListBox1.Items[ListBox1.ItemIndex]]); Hope that helps. = Steve |
Thu, Jul 16 2015 6:44 PM | Permanent Link |
Trinione | << Steve Gill wrote:
Hi Trinione, I use a TStringList to get around this. When I add the values to the Listbox, I also add them to the StringList. ListBox1.AddItem('Item 1'); StringList1.Values['Item 1'] := IntToStr(111); Then when the value is selected in the ListBox, I read the corresponding value from the StringList. ShowMessage(StringList1.Values[ListBox1.Items[ListBox1.ItemIndex]]); Hope that helps.>> Steve: Thanks. That does help and is great reference if and when I use this method in the future. Hopefully the EWB would have the ability to store a code/value along with the text at some point, or the AddObject() method as is the standard way to do it in Delphi. What I decided to go with though is using an un-bound Grid with the first column Visibile := False and Width := 0. With Grid1 do begin AppendRow; intCurrentRow := RowCount - 1; Rows[intCurrentRow][0] := sCode; Rows[intCurrentRow][1] := sMemberName; end; The selected row data is retrieved via: sSelectedCode := Grid1.Rows[Grid1.RowIndex][0]; Much simpler to manage. |
Fri, Jul 17 2015 6:43 PM | Permanent Link |
Steve Gill | Hi Trinione,
<< What I decided to go with though is using an un-bound Grid with the first column Visibile := False and Width := 0.>> That's what I do as well when I am using a TGrid although I generally use the last column, not that it makes any difference. = Steve |
This web page was last updated on Friday, December 1, 2023 at 06:01 PM | Privacy Policy![]() © 2023 Elevate Software, Inc. All Rights Reserved Questions or comments ? ![]() |