unit Unit2;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, cxGraphics, cxControls, cxLookAndFeels,
cxLookAndFeelPainters, dxNavBarGroupItems, dxNavBarCollns, cxClasses,
dxNavBarBase, dxNavBar, Vcl.StdCtrls, System.Actions, Vcl.ActnList,
Vcl.PlatformDefaultStyleActnCtrls, Vcl.ActnMan, cxContainer, cxEdit,
Vcl.WinXCtrls, cxTextEdit, dxOfficeSearchBox, cxMaskEdit, cxDropDownEdit,
dxCalloutPopup, dxBar, Vcl.Menus, Vcl.ActnPopup;
type
TForm2 = class(TForm)
Memo1: TMemo;
Button1: TButton;
ActionManager1: TActionManager;
Action1: TAction;
Action2: TAction;
Action3: TAction;
Action4: TAction;
dxNavBar1: TdxNavBar;
dxOfficeSearchBox1: TdxOfficeSearchBox;
SearchBox1: TSearchBox;
PopupActionBar1: TPopupActionBar;
asdfasdf1: TMenuItem;
fffadfasdf1: TMenuItem;
N1: TMenuItem;
dxBarPopupMenu1: TdxBarPopupMenu;
dxCalloutPopup1: TdxCalloutPopup;
cxPopupEdit1: TcxPopupEdit;
procedure Button1Click(Sender: TObject);
procedure asdfasdf1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
function GetAcitonByCaption(const aCategory,aCaption: string): Integer;
end;
var
Form2: TForm2;
implementation
{$R *.dfm}
function TForm2.GetAcitonByCaption(const aCategory,aCaption: string): Integer;
var
i: Integer;
begin
Result := -1;
for i := 0 to ActionManager1.ActionCount-1 do
begin
if System.SysUtils.SameText(TAction(ActionManager1.Actions[i]).Category,aCategory) and
System.SysUtils.SameText(TAction(ActionManager1.Actions[i]).Caption,aCaption)
then
begin
Result := i;
Exit;
end;
end;
end;
procedure TForm2.asdfasdf1Click(Sender: TObject);
begin
//dxNavBar1.GetLinkAtSelectedPos(System.Bindings.Eval);
end;
procedure TForm2.Button1Click(Sender: TObject);
var
aBarItem:TdxNavBarItem;
aBarGroup:TdxNavBargroup;
iAction :Integer;
begin
dxNavBar1.Items.Clear;
dxNavBar1.Groups.Clear;
//++++++++++++++++++++++++++++++++++++++++++++++++//
aBarGroup:=dxNavBar1.Groups.Add;
aBarGroup.Caption := '系统设置';
aBarItem:=dxNavBar1.Items.Add;
aBarItem.Caption:= '我靠';
aBarGroup.CreateLink(aBarItem);
//aBarItem.OnClick:= button1.OnClick; //绑定事件
//iAction := GetAcitonByCaption(cds_Master.FieldByName(aBarItem.Caption).AsString,sMenu);
//aBarItem.Action := TAction(ActionManager1.Actions[iAction]);
aBarItem:=dxNavBar1.Items.Add;
aBarItem.Caption := '我草';
aBarGroup.CreateLink(aBarItem);
//iAction := GetAcitonByCaption(cds_Master.FieldByName(aBarItem.Caption).AsString,sMenu);
// aBarItem.Action := TAction(ActionManager1.Actions[iAction]); aBarGroup.CreateLink(aBarItem);
aBarGroup:=dxNavBar1.Groups.Add;
aBarGroup.Caption := '权限管理';
aBarItem:=dxNavBar1.Items.Add;
aBarItem.Caption:= '权限1';
aBarGroup.CreateLink(aBarItem);
//aBarItem.OnClick:= button1.OnClick; //绑定事件
//iAction := GetAcitonByCaption(cds_Master.FieldByName(aBarItem.Caption).AsString,sMenu);
//aBarItem.Action := TAction(ActionManager1.Actions[iAction]);
aBarItem:=dxNavBar1.Items.Add;
aBarItem.Caption := '权限2';
aBarGroup.CreateLink(aBarItem);
aBarGroup:=dxNavBar1.Groups.Add;
aBarGroup.Caption := '订单管理';
aBarItem:=dxNavBar1.Items.Add;
aBarItem.Caption:= '打印订单';
aBarGroup.CreateLink(aBarItem);
//aBarItem.OnClick:= button1.OnClick; //绑定事件
//iAction := GetAcitonByCaption(cds_Master.FieldByName(aBarItem.Caption).AsString,sMenu);
//aBarItem.Action := TAction(ActionManager1.Actions[iAction]);
aBarItem:=dxNavBar1.Items.Add;
aBarItem.Caption := '扫描发货';
aBarGroup.CreateLink(aBarItem);
end;
end.
标签:Vcl,devexpress,dxNavBar,aBarGroup,用法,Caption,aBarItem,TAction,dxNavBar1
From: https://www.cnblogs.com/del88/p/18309226