从数据库里取得数据,动态的生成菜单。我的代码如下:
procedure TForm1.FormCreate(Sender: TObject);
var
theActionClients1:TActionClients;
theActionClients2:TActionClientItem;
begin
theActionClients1:=ActionManager1.ActionBars[0].Items;
theActionClients2:=theActionClients1.Add;
theActionClients2.Caption:='111';
theActionClients2.Visible:=True;
theActionClients2.DisplayName:='222'; ShowMessage(IntToStr(ActionManager1.ActionBars[0].Items.Count));
end;
程序运行起来显示的结果为,但是在ActionMainMenuBar里就是看不见按钮,郁闷!
procedure TForm1.FormCreate(Sender: TObject);
var
theActionClients1:TActionClients;
theActionClients2:TActionClientItem;
begin
theActionClients1:=ActionManager1.ActionBars[0].Items;
theActionClients2:=theActionClients1.Add;
theActionClients2.Caption:='111';
theActionClients2.Visible:=True;
theActionClients2.DisplayName:='222'; ShowMessage(IntToStr(ActionManager1.ActionBars[0].Items.Count));
end;
程序运行起来显示的结果为,但是在ActionMainMenuBar里就是看不见按钮,郁闷!
解决方案 »
- delphi中的清屏语句如何写?很急!!!
- 怎么用程序将SQL SERVER2000中表abc 导出和导入?
- 关于dll的问题,请指点!
- Indy如何通过防火墙(400分求解)。
- #######怎样写屏幕保护程序?要保证能加入密码。#######
- 将照相机图片90度立起来导出
- 求救:合并richedit富文本与图片处理
- 怎样学好delphi???........
- 大家好,请问大家,从数据库中将一个表的某个字段的全部记录读入到一个Tlist中
- Delphi 6 Bug Report !!!!!!!
- 【不死鸟的散分贴之四……】郁闷之一...发现有人反对我散分的时候占一楼....
- 在ReportBuilder上放什么控件可以画线呀,急!
后来索性预先做好一定数量的taction,并生成菜单,在运行时控制它们的visible属性。希望看到更好的答案出现。
但是问题又来了,因为这个办法毕竟不是正路呀,想在"111111"下在创建菜单项目就又看不见了。
var
theActionClients1:TActionClients;
theActionClients2:TActionClientItem;
begin
theActionClients1:=ActionManager1.ActionBars[0].Items;
theActionClients2:=theActionClients1.Add;
theActionClients2.Caption:='111111';
theActionClients2.Visible:=True;
//以下是后加的
theActionClients1:=theActionClients2.Items;
theActionClients2:=theActionClients1.Add;
theActionClients2.Caption:='222222';
theActionClients2.Visible:=True;
end;
仍然看不见"222222",但是情况下是不可能在设计期间去创建一个菜单项目,然后设置成不可见了,因为"111111"在设计期间根本不存在...:(
theActionClients1:=theActionClients2.Items;
theActionClients2:=theActionClients1.Add;
theActionClients2.Caption:='222222';
theActionClients2.Visible:=True;
这段代码的意思是:在"111111"的下面再挂一层菜单"222222"。很遗憾,显示不出来。
这个东西可真麻烦!
要是动态加载的话需要创建的东西可真不少呀,麻烦呀