写个通用的方法。。
我的代码如下。好心的人帮我改下。。
形如QQ创建组的功能模块(最近做的短信平台软件需要动态创组的问题):
//创建组
procedure TMain.SaveGroup;
//var
//Group :TRzGroup;
//NameItem :TRzGroupItem;
begin
with qry1 do
begin
Close;
SQL.Clear;
SQL.Add('select GroupName,Id from SMB_Group');
Open;
while not Eof do
begin
Group :=TRzGroup.Create(Self);
RzGroupBar1.AddGroup(Group);
Group.Caption :=FieldByName('Groupname').AsString;
Group.SmallImages:=ImageList1;
Group.PopupMenu :=pm2;
Group.OnDblClick:=frmZSFormCreate;
Group.OnMouseMove:=xonMove;
// ZS.Panel2.Caption :=Group.Caption;
with qry4 do
begin
Close;
SQL.Clear;
SQL.Add('select * from SMS_PHBK');
Open;
while not Eof do
begin
with qry2 do
begin
Close;
SQL.Clear;
SQL.Add('select * from SMB_Group_User where GID='+qry1.FieldByName('ID').AsString+'and UID ='+qry4.FieldByName('ID').AsString);
Open;
while not eof do
begin
NameItem :=Group.Items.Add;
NameItem.ImageIndex:=Random(Group.Items[0].ImageIndex);
NameItem.Caption :=qry4.FieldByName('LINa').AsString;
NameItem.Enabled :=True;
NameItem.OnClick :=N3Click;
Next;
end;
end;
Next;
end;
end;
Next;
end;
end;
end;