我现在将dxNavBar控键的view设为了AdvExplorerBarView,这样设置后我再也无法根据我所点的分组内容得到分组名称了。
用dxNavBar1.ActiveGroup.Caption这个方法属性一直都是得到第一个组的名称。我想根据我所点选的分组内容来得到分组的名称该怎么办呀????注:dxNavBar1.ActiveGroup.Caption在dxNavBar控键的view设为XP1View的时候可以取得不同分组的名称。但是在view设为了AdvExplorerBarView就不行了。

解决方案 »

  1.   

    如果是在点分组的时候想获取分组的名称可以
    dxNavBar.OnGroupClick函数中获取当前点击的分组名称.
    eg:
    procedure TForm1.dxNavBar1GroupClick(Sender: TObject;
      AGroup: TdxNavBarGroup);
    begin
      ShowMessage(AGroup.Caption);
    end;如果想在点击Item的时候获取其所属分组的名称,则在Item的OnClick事件中编写循环遍历代码
    procedure TForm1.dxnvbrtmNavBar1Item2Click(Sender: TObject);
    var
      i,j: integer;
    begin
      for i := 0 to dxNavBar1.Groups.Count -1  do
      begin
        for j := 0 to dxNavBar1.Groups[i].LinkCount -1 do
        begin
          if  (dxNavBar1.Groups[i].Links[j].Item.Caption) = 
                   (sender as TdxNavBarItem).Caption then
           begin
              showmessage(dxNavBar1.Groups[i].caption);
              Exit;
           end;
        end;
      end;
    end;
      

  2.   

    如果是在点分组的时候想获取分组的名称可以
    dxNavBar.OnGroupClick函数中获取当前点击的分组名称.
    eg:
    procedure TForm1.dxNavBar1GroupClick(Sender: TObject;
      AGroup: TdxNavBarGroup);
    begin
      ShowMessage(AGroup.Caption);
    end;如果想在点击Item的时候获取其所属分组的名称,则在Item的OnClick事件中编写循环遍历代码
    procedure TForm1.dxnvbrtmNavBar1Item2Click(Sender: TObject);
    var
      i,j: integer;
    begin
      for i := 0 to dxNavBar1.Groups.Count -1  do
      begin
        for j := 0 to dxNavBar1.Groups[i].LinkCount -1 do
        begin
          if  (dxNavBar1.Groups[i].Links[j].Item.Caption) = 
                   (sender as TdxNavBarItem).Caption then
           begin
              showmessage(dxNavBar1.Groups[i].caption);
              Exit;
           end;
        end;
      end;
    end;