Lazarus
Programming => LCL => Topic started by: morphocr on May 14, 2011, 02:02:11 am
-
it works on the combobox.items but not in tabcontrol.tabs and both use tstrings
tmyclass = class
tt : integer;
a : string;
end;
.
.
.
procedure TForm1.Button1Click(Sender: TObject);
var
i : integer;
temp : tmyclass;
begin
for i := 1 to 10 do
begin
temp := tmyclass.Create;
temp.a:='object#'+inttostr(i);
temp.tt:=i;
ComboBox1.Items.AddObject(temp.a,temp);
TabControl1.Tabs.AddObject(temp.a,temp);
end;
for i := 0 to ComboBox1.Items.Count-1 do
begin
showmessage(inttostr(tmyclass(ComboBox1.Items.Objects[i]).tt));
showmessage(inttostr(tmyclass(TabControl1.tabs.Objects[i]).tt));
end;
end;
-
What error do you get?
It would also be useful if you give details about Lazarus / Freepascal version, etc.
Gr.
Dirk.
-
What error do you get?
It would also be useful if you give details about Lazarus / Freepascal version, etc.
Gr.
Dirk.
thanks for your reply,
when trying to get any objects fromTabControl1.tabs.Objects[i]
it come with -(maxInteger) value instead of the object pointer, and im using the
follow Ide :
- Lazarus Version #: 0.9.30
- Date: 2011-05-13
- FPC Version: 2.4.2
- SVN Revision: 29811M
for i386-linux-gtk 2 on Fedora 14 Box
-
anyone follow this ?
-
I'm assuming this is because ComboBox1.Items and TabControl1.Tabs are different beasts.
ComboBox.Items is an actual TStringList (which has the Objects property implemented as expected).
TabControl.Tabs is a TTabControlNoteBookStrings that has some fancy methods (not in the least an overriden PutObject(...)).
Just create a separate TStringList where you store the info you need for your tabs.