回答2:
在开始时定义:
unit uQXGL;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ImgList, ComCtrls, StdCtrls, Grids, DBGrids, Buttons, ExtCtrls, ToolWin,
Db, DBTables;
type
rdNode=Record
psDM : String[20];
psQX : String[20];
End;
TpRYNode = ^rdNode ;//人员节点指针
TpStr = ^String;
TfmMain = class(TForm)
StatusBar1: TStatusBar;
CoolBar1: TCoolBar;
pnl_Main: TPanel;
Panel5: TPanel;
....
在程序中
if TpStr(ltSelListItem.Data)^=TpStr(ListView1.Items.Item
[fiNum].Data)^
或是
procedure TfmMain.IniTreeView ;
Var
ndFirstNode,ndAddNode:TTreeNode ;
pStr:TpRYNode;
sSql:String;
Begin
//ndFirstNode:=TTreeNode.Create(TreeView1.TopItem.Owner);
TreeView1.Items.Clear ;
ndFirstNode:=TreeView1.Items.Add(nil,'管理人员'); // urs.rs_ryjc //a.RYDM ZGDM USERID
sSql:='Select distinct a.RYDM DM ,b.username MC from SJ_DD_JDBH_QXWJ a ,uzh.zk_qxb b where a.RYDM=b.USERID ';
QueryOpen(Dm.Query1,sSql); //XM
With Dm.Query1 do Begin
While Not Eof do
Begin
ndAddNode:=TreeView1.Items.AddChild(ndFirstNode,FieldByName('MC').AsString);
New(pStr);
pStr^.psDM := FieldByName('DM').AsString ;
//pStr^.psQX := FieldByName('GLQX').AsString ;
ndAddNode.Data := pStr ;
Next ;
End;
Close;
End;
TreeView1.TopItem.Expand(True);
End;//End procedure
懂了吗?
如果有什么疑问,请告诉我
对了,