Stores an integer value as part of a component.
Delphi的帮助:property Tag: Longint;Description:Tag has no predefined meaning. The Tag property is provided for the convenience of storing additional integer value or pointer information for special needs in an application. For example, use the Tag property when implementing case statements with a component.
Delphi的帮助:property Tag: Longint;Description:Tag has no predefined meaning. The Tag property is provided for the convenience of storing additional integer value or pointer information for special needs in an application. For example, use the Tag property when implementing case statements with a component.
例如你给需要判断的CheckBox的"tag"都标上一个特殊的值,例如,如果这16个CheckBox是一视同仁的话,可以标上相同的100(例如说),然后你循环判断时,使用窗口的Controls属性来枚举窗口中的所有控件,然后判断控件的类型是否是TCheckBox(TForm.Controls[i] is TCheckBox),同时判断tag属性是否为100(TForm.Controls[i].Tag=100)。
例如在一个Form上放上好几个Button然后在
case Button?.Tag of
0: ShowMessage('0');
1: ShowMessage('1');
2: ShowMessage('2');
3: ShowMessage('3');
4: ShowMessage('4');
5: ShowMessage('5');
end;
就知道了。
哦,小弟第一次使用Tag。呵呵
-------------------------------------------------------
popupmenu.tag:=integer(toolbar);
---------------------------------------------------------
procedure popupmenuclick(sender:tobject);
begin
popupmenu.checked:=not popupmenu.checked;
ttoolbar(popupmenu.tag).visible:=popupmemu.checked;
end;
如上可实现toolbar的隐现
case myvcl.tag 做不同处理,简化代码。