1stClass控件组的TfcButtonGroup问题.请大侠帮忙......(50分)

  • 主题发起人 主题发起人 zml
  • 开始时间 开始时间
Z

zml

Unregistered / Unconfirmed
GUEST, unregistred user!
我建立了一个TfcButtonGroup.想在里面动态的加入TfcShapeBtn.试了几个属性都不行
请大家帮帮忙.
 
鼠标移到TfcButtonGroup,点击右键,再点选new button,就可加TfcShapeBtn.
 
我的意思是动态用语句插入.谢谢你了.
 
TfcButtonGroup.items.add
 
你这样可以增加控件上去.但是如何增加上去的TfcShapeBtn进行操作.麻烦给段代码好不好?
很急很急谢谢!!!
 
precedure xxx;
begin
do something
end;

fcshapebtn.click:=xxx;
依此类推
 
我怎么去取刚刚新增的fcshapebtn控件.
precedure xxx;
begin
do something
end;

TfcButtonGroup.items.add
--新增以后我怎么去找这个控件怎么赋事件给这个控件.麻烦先试验一下把源代码给我.
--比如我新增控件后要把新增后的控件caption改为aaa怎么做.



 
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
fcButton, fcImgBtn, fcShapeBtn, ExtCtrls, fcClearPanel, fcButtonGroup;

type
TForm1 = class(TForm)
fcButtonGroup1: TfcButtonGroup;
fcButtonGroup1fcShapeBtn1: TfcShapeBtn;
fcButtonGroup1fcShapeBtn2: TfcShapeBtn;
fcShapeBtn1: TfcShapeBtn;
procedure fcShapeBtn1Click(Sender: TObject);
procedure a(Sender: TObject);
private
{ Private declarations }

public
{ Public declarations }

end;

var
Form1: TForm1;

implementation

{$R *.DFM}
//button click message
procedure TForm1.a;
begin
application.MessageBox('ss','s',mb_ok);
end;
//add a button
procedure TForm1.fcShapeBtn1Click(Sender: TObject);

var
but1:TfcButtonGroupItem;
begin
but1:=fcButtonGroup1.ButtonItems.Add;
but1.Button.Caption:='lll';
but1.Button.OnClick:=a;
end;

end.
 
如果我要增加多个该怎么办?
 

var
but1:array[0.10] of TfcButtonGroupItem;
射为全局变量来保存句柄

在退出时:如果有n个句柄
for i:=0 to n-1 do
begin
but1.free;
end;

 
我是未知个,因为我准备用它来做菜单.所有的菜单列都是从数据表里抓取的,可能是未知的.
怎么办?
 
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
fcButton, fcImgBtn, fcShapeBtn, ExtCtrls, fcClearPanel, fcButtonGroup,
ADODB, Db, Grids, DBGrids, StdCtrls;
//既然是未知个:
//那么就用:Tlist;
type
PMyList = ^AList;
AList = record
btn:TfcButtonGroupItem
btnid:integer;//标示button
end;

type
TForm1 = class(TForm)
fcButtonGroup1: TfcButtonGroup;
fcButtonGroup1fcShapeBtn1: TfcShapeBtn;
fcButtonGroup1fcShapeBtn2: TfcShapeBtn;
fcShapeBtn1: TfcShapeBtn;
procedure fcShapeBtn1Click(Sender: TObject);
procedure a(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
{ Private declarations }

public
{ Public declarations }
MyList: TList;
ARecord: PMyList;
end;

var
Form1: TForm1;

implementation

{$R *.DFM}
//button click message
procedure TForm1.a;
begin
application.MessageBox('ss','s',mb_ok);
end;
//add a button
procedure TForm1.fcShapeBtn1Click(Sender: TObject);

begin
New(ARecord);
arecord.btnid:=1;//你的标师
arecord^.btn:=fcButtonGroup1.ButtonItems.Add;
arecord^.Button.Caption:='lll';
arecord^.Button.OnClick:=a;//对应消息

end;

procedure TForm1.FormShow(Sender: TObject);
begin
MyList := TList.Create;


end;

procedure TForm1.FormDestroy(Sender: TObject);
var
i:integer;
begin
for i:=0 to mylist.count-1 do
begin
ARecord:=mylist.items;
dispose(arecord);
end;
mylist.free;
end;

end.




 
后退
顶部