读书人

这个应该如何调用

发布时间: 2012-03-12 12:45:33 作者: rapoo

这个应该怎么调用
程序在运行时动态创建多个TcxLabel,对应同一个pmKS : TPopupMenu.

自定义一个更改TcxLabel颜色和HINT的过程.
procedure TfrmFTB.SetHouseProperty(T_cxLable: TcxLabel; HouseState : string);
begin
if houseState = '预留 ' then T_cxLable.Style.Color := clbHouseKS.Style.Color
else ... ;

if HouseState = '预留 ' then begin
T_cxLable.Hint := '...... ';

end;

我想在右击某个TcxLabel,再单击某个PopupMenu的菜单项后调用以上的过程
SetHouseProperty(TcxLabel(pmKS.PopupComponent.Name), '预留 ');

程序在T_cxLable.Style.Color := clbHouseKS.Style.Color出错,不知道调用方法对不对?

[解决办法]
好象没有错。但不知你的出错原因是什么回事,改用其它颜色试下。
[解决办法]
1、这个地方要改:
SetHouseProperty(TcxLabel(pmKS.PopupComponent.Name), '预留 ');
改为:
if FindComponent(pmKS.PopupComponent.Name) <> Nil then
SetHouseProperty(TcxLabel(FindComponent(pmKS.PopupComponent.Name)), '预留 ');
2、这个地方不知要不要改:
如果你是使用TcxColorComboBox,则使用ColorValue这个属性
T_cxLable.Style.Color := clbHouseKS.ColorValue
[解决办法]
嗯,不好意思,没看出来
帮你顶
[解决办法]
调试调试
[解决办法]
学习
[解决办法]
1、SetHouseProperty(TcxLabel(pmKS.PopupComponent.Name), '预留 ');
如果确认调用popupmenu的是TcxLabel那么直接用
SetHouseProperty(TcxLabel(pmKS.PopupComponent), '预留 ');
在函数里判断一下T_cxLable <> nil
不确认则判断一下
if (pmKS.PopupComponent <> nil) and (comparetext(pmKS.PopupComponent.classname, 'TcxLabel ') = 0 )then
SetHouseProperty(TcxLabel(pmKS.PopupComponent), '预留 ');
出错的原因应该是你的T_cxLable值没有正确取到吧

读书人网 >.NET

热点推荐