Gary4
asked on
Delphi / Firemonkey Combo Box values, possable?
Hi,
I want to have a selected value that is different than the displayed value?
It is possible to do this in HTML and in .net.
Is it possible to do this in Delphi/FireMonkey Mobile?
When I go into the ComboBox Items Designer it only shows a place to enter the display text.
Likewise in the Object Inspector, the Combo Box items look more like ListView items with text only, no values.
My desire is to have unique values for the displayed items that can be stored in a DB table and used against a lookup table.
I would also like to have the combo items populated form that same lookup table, but I don't see any way to do that with Live Bindings.
Gary
I want to have a selected value that is different than the displayed value?
It is possible to do this in HTML and in .net.
Is it possible to do this in Delphi/FireMonkey Mobile?
When I go into the ComboBox Items Designer it only shows a place to enter the display text.
Likewise in the Object Inspector, the Combo Box items look more like ListView items with text only, no values.
My desire is to have unique values for the displayed items that can be stored in a DB table and used against a lookup table.
I would also like to have the combo items populated form that same lookup table, but I don't see any way to do that with Live Bindings.
Gary
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
@Sinisa Vuk
Hi,
I came back to this for the same problem on another project. This time I used your solution since I couldn't use Live Bindings this time.
I wish I could give you 500 more points and up the rating!
Hi,
I came back to this for the same problem on another project. This time I used your solution since I couldn't use Live Bindings this time.
I wish I could give you 500 more points and up the rating!
Glad that my comment helps ....
ASKER
Hi,
Sorry to be a pest, however,
There seems to be a problem in my code.
This code is in a data module. The control is passed in from a from. The control is on the form.
InterestTB is a FireDac FDTable on the data module.
Any thoughts?
The code ran fine with win32 as the target.
It's failing with Android as the target.
Sorry to be a pest, however,
There seems to be a problem in my code.
This code is in a data module. The control is passed in from a from. The control is on the form.
InterestTB is a FireDac FDTable on the data module.
procedure TChirpMaxDB.FillddChannel(ddChannel: TComboBox);
var
I: Integer;
sb: string;
begin
ddChannel.BeginUpdate;
ddChannel.Items.Clear;
with InterestTB do
Begin
Active := True;
First;
while (not Eof) do
begin
I := FieldByName('ID').AsInteger;
sb := FieldByName('Name').AsString;
ddChannel.Items.AddObject(sb, TObject(I)); // <-- It fails on this line on the first iteration.
Next;
End;
Active := False;
End;
ddChannel.ItemIndex := 0;
ddChannel.EndUpdate;
ddChannel.Repaint;
end;
Any thoughts?
The code ran fine with win32 as the target.
It's failing with Android as the target.
Why don't you say - android? :-)
Unfortunately, .AddObject doesn't work on android/ios. Had same problem too.
Read this on this blog and how to overcome this:
http://blogs.riversoftavg. com/index. php/2013/0 8/01/using -primitive -types-wit h-tstrings -in-ios/
Unfortunately, .AddObject doesn't work on android/ios. Had same problem too.
Read this on this blog and how to overcome this:
http://blogs.riversoftavg.
ASKER
I did say Firemonkey, implying cross platform. :-)
One would think they would throw a compile error rather then leaving it laying around to trip over like some scripting language.
The again, one would think if they knew about it they would 'make' it work like they did other things.
I spent about ten years with .net and never thought twice about 'boxing', except as a possible performance penalty.
Thanks again :-)
I think this is now my go to place for Delphi/Firemonkey help.
One would think they would throw a compile error rather then leaving it laying around to trip over like some scripting language.
The again, one would think if they knew about it they would 'make' it work like they did other things.
I spent about ten years with .net and never thought twice about 'boxing', except as a possible performance penalty.
Thanks again :-)
I think this is now my go to place for Delphi/Firemonkey help.
No problem. As I'm sw developer with full time job (using Delphi), sometimes I come to problems before others :-)
ASKER
I'm a full time developer too, I find it objectionable to stumble over problems in my development tools.
In this case the compiler is generating bad code and if storing an integer as an object is not part of the language it should have thrown an error.
I spent 12 hours futzing with this. Time I should have spent making a TEdit scroll.
Are you part of the hire-a-pro thing they recently announced?
In this case the compiler is generating bad code and if storing an integer as an object is not part of the language it should have thrown an error.
I spent 12 hours futzing with this. Time I should have spent making a TEdit scroll.
Are you part of the hire-a-pro thing they recently announced?
No, maybe will be in future :-) couse I'm short with time these days....
ASKER
Fair enough. I was only thinking of short term things that stump me. Maybe of a day or less. I didn't have anything in mind right now.
ASKER
However, your code did help me with some other issues I had.