Re: Add String in AddObject method and retrieving its va lue
"ebis007de" <[email protected]>
| Newsgroups | gmane.comp.lang.delphi.programming |
|---|---|
| Message-ID | <[email protected]> |
> > I though something like this but must have something wrong..
> > hope someone can help
> >
> > list : Tstrings
> > q :query
> >
> > I've tried some ways... but doesn´t work.
> >
> > while not q.eof do begin
> > List.addObject(q.fieldbyname('FullName').asstring,
> >
> > TObject(q.fieldbyname('ShortName').asstring)) //
> > also put the string word after TObject and looks like
> > TObject(String(q.Fieldby....
> > q.next;
> > end;
> >
> > ComboBoxOnChange(Sender:Tobject);
> > begin
> > with TComboBox(Sender) do
> > Showmessage(string(items.object[itemindex]))
> > end;
> >
You can't do that in this way because the string-handling is a bit
special in Delphi. See more in the Delphi help
What you can do (short example out of my head)
Type TPerson = Class
public
Constructor Create (_Short: String);
ShortName : String;
end;
Constructor Create (_Short: String);
begin
Shortname := _Short;
end;
while not q.eof do begin
List.addObject(q.fieldbyname('FullName').asstring,
TObject(TPerson.Create (q.fieldbyname
('ShortName').asstring));
q.next;
end;
ComboBoxOnChange(Sender:Tobject);
begin
ShowMessage (TPerson (TComboBox(Sender)items.objects
[itemindex])).ShortName)
end;
Bests Ebi
------------------------ Yahoo! Groups Sponsor ---------------------~-->
Buy Ink Cartridges or Refill Kits for Your HP, Epson, Canon or Lexmark
Printer at Myinks.com. Free s/h on orders $50 or more to the US & Canada.
http://www.c1tracking.com/l.asp?cid=5511
http://us.click.yahoo.com/sOykFB/k9VGAA/ySSFAA/i7folB/TM
---------------------------------------------------------------------~->
Delphi Tips & Tutorials...
http://www.delphicollection.com
---------------------------------------------------------------
Unsubscribe:[email protected]
List owner:[email protected]
---------------------------------------------------------------
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/