type
PMyRec = ^TMyRec;
TMyRec = record
FName: string;
LName: string;
end;Assuming these types are used, the following code adds a node to TreeView1 as the last sibling of a specified node. A TMyRec record is associated with the added item. The FName and LName fields are obtained from edit boxes Edit1 and Edit2. The Index parameter is obtained from edit box Edit3. The item is added only if the Index is a valid value.procedure TForm1.Button1Click(Sender: TObject);var
MyRecPtr: PMyRec;
TreeViewIndex: LongInt;
begin
New(MyRecPtr);
MyRecPtr^.FName := Edit1.Text;
MyRecPtr^.LName := Edit2.Text;
TreeViewIndex := StrToInt(Edit3.Text);
with TreeView1 do
begin
if Items.Count = 0 then
Items.AddObject(nil, 'Item' + IntToStr(TreeViewIndex), MyRecPtr)
elseif (TreeViewIndex < Items.Count) and (TreeViewIndex >= 0) then
Items.AddObject(Items[TreeViewIndex], 'Item' + IntToStr(TreeViewIndex), MyRecPtr); end;
end;After an item containing a TMyRec record has been added, the following code retrieves the FName and LName values associated with the item and displays the values in a label.procedure TForm1.Button2Click(Sender: TObject);begin
Label1.Caption := PMyRec(TreeView1.Selected.Data)^.FName + ' ' +
PMyRec(TreeView1.Selected.Data)^.LName;
end;
PMyRec = ^TMyRec;
TMyRec = record
FName: string;
LName: string;
end;Assuming these types are used, the following code adds a node to TreeView1 as the last sibling of a specified node. A TMyRec record is associated with the added item. The FName and LName fields are obtained from edit boxes Edit1 and Edit2. The Index parameter is obtained from edit box Edit3. The item is added only if the Index is a valid value.procedure TForm1.Button1Click(Sender: TObject);var
MyRecPtr: PMyRec;
TreeViewIndex: LongInt;
begin
New(MyRecPtr);
MyRecPtr^.FName := Edit1.Text;
MyRecPtr^.LName := Edit2.Text;
TreeViewIndex := StrToInt(Edit3.Text);
with TreeView1 do
begin
if Items.Count = 0 then
Items.AddObject(nil, 'Item' + IntToStr(TreeViewIndex), MyRecPtr)
elseif (TreeViewIndex < Items.Count) and (TreeViewIndex >= 0) then
Items.AddObject(Items[TreeViewIndex], 'Item' + IntToStr(TreeViewIndex), MyRecPtr); end;
end;After an item containing a TMyRec record has been added, the following code retrieves the FName and LName values associated with the item and displays the values in a label.procedure TForm1.Button2Click(Sender: TObject);begin
Label1.Caption := PMyRec(TreeView1.Selected.Data)^.FName + ' ' +
PMyRec(TreeView1.Selected.Data)^.LName;
end;
解决方案 »
- Delphi 修复注册表文件关联
- 请教高手做出这道面试题http://www.tongchan.com/kaoshishiti.htm , 必有重谢!!!!
- button无法正常显示
- 做为一个DELPHI的编程人员,数据库要学到什么程度啊?
- 常见小问题,在线等!!!!
- <<<<<<<<<<及其简单<<<<送分: Delphi中Char字符如何进行大、小写转换?>>>>>>>>>>>
- 怎样旋转一个画布中的Rect(T,L,R,B)区域,求救!
- 哪位大虾帮我解决以下问题
- 为何ClientDataSet1.ApplyUpdates(-1)不能更新数据?
- 又是一个菜鸟问题~~~~~:)
- 高手帮忙!!!
- 很简单的问题?
你想放啥就放啥!
或者资料什么地方有?
谢谢
http://www.csdn.net/expert/topic/554/554678.xml?temp=.9892694
or
1stclass 关键字查找