以上是静态建立。 动态建立:procedure TForm1.FormCreate(Sender: TObject); const s:array[0..4]of string=('华中分公司','华南分公司','密码修改','用户管理','关于'); var i:integer; begin dxNavBar1.Groups.Add; dxNavBar1.Groups.Items[0].Caption:='业务菜单'; dxNavBar1.Groups.Items[1].Caption:='系统设置'; for i:= 0 to 4 do begin dxNavBar1.Items.Add; dxNavBar1.Items.Items[i].Caption:=s[i]; if i<2 then dxNavBar1.Groups.Items[0].CreateLink(dxNavBar1.Items.Items[i]) else dxNavBar1.Groups.Items[1].CreateLink(dxNavBar1.Items.Items[i]); end; end;
补充和勘误一下,如下:procedure TForm1.dxNavBarItemClick(Sender: TObject); begin showmessage(TdxNavBarItem(Sender).Caption+'被点击了'); end;procedure TForm1.FormCreate(Sender: TObject); const s:array[0..4]of string=('华中分公司','华南分公司','密码修改','用户管理','关于'); var i:integer; begin dxNavBar1.Groups.Add; dxNavBar1.Groups.Add; //刚才漏了一次建立 dxNavBar1.Groups.Items[0].Caption:='业务菜单'; dxNavBar1.Groups.Items[1].Caption:='系统设置'; for i:= 0 to 4 do begin dxNavBar1.Items.Add; dxNavBar1.Items.Items[i].Caption:=s[i]; if i<2 then dxNavBar1.Groups.Items[0].CreateLink(dxNavBar1.Items.Items[i]) else dxNavBar1.Groups.Items[1].CreateLink(dxNavBar1.Items.Items[i]); dxNavBar1.Items.Items[i].OnClick:=dxNavBarItemClick;//关联点击事件 end; end;
动态建立:procedure TForm1.FormCreate(Sender: TObject);
const s:array[0..4]of string=('华中分公司','华南分公司','密码修改','用户管理','关于');
var i:integer;
begin
dxNavBar1.Groups.Add;
dxNavBar1.Groups.Items[0].Caption:='业务菜单';
dxNavBar1.Groups.Items[1].Caption:='系统设置';
for i:= 0 to 4 do begin
dxNavBar1.Items.Add;
dxNavBar1.Items.Items[i].Caption:=s[i];
if i<2 then
dxNavBar1.Groups.Items[0].CreateLink(dxNavBar1.Items.Items[i])
else
dxNavBar1.Groups.Items[1].CreateLink(dxNavBar1.Items.Items[i]);
end;
end;
begin
showmessage(TdxNavBarItem(Sender).Caption+'被点击了');
end;procedure TForm1.FormCreate(Sender: TObject);
const s:array[0..4]of string=('华中分公司','华南分公司','密码修改','用户管理','关于');
var i:integer;
begin
dxNavBar1.Groups.Add;
dxNavBar1.Groups.Add; //刚才漏了一次建立
dxNavBar1.Groups.Items[0].Caption:='业务菜单';
dxNavBar1.Groups.Items[1].Caption:='系统设置';
for i:= 0 to 4 do begin
dxNavBar1.Items.Add;
dxNavBar1.Items.Items[i].Caption:=s[i];
if i<2 then
dxNavBar1.Groups.Items[0].CreateLink(dxNavBar1.Items.Items[i])
else
dxNavBar1.Groups.Items[1].CreateLink(dxNavBar1.Items.Items[i]);
dxNavBar1.Items.Items[i].OnClick:=dxNavBarItemClick;//关联点击事件
end;
end;