uniGUI之多页面框架(16)

效果图:uniGUI之多页面框架(16)_第1张图片

 

uniGUI之多页面框架(16)_第2张图片

 

 左边的树 的树结点 ,通过 结点名 与 右 侧TabSheet名 一致时,显示 相关页面。

这是相关 源代码

procedure TMainForm.UniFormCreate(Sender: TObject);
var
  I: Integer; 
begin
  for I := UniPageControl1.PageCount - 1 downto 1 do // 一定是  downto 1
  begin
    UniPageControl1.Pages[I].Visible := false;
    UniPageControl1.Pages[I].TabVisible := false;
  end;
  UniPageControl1.ActivePageIndex:=0;//设计 时, 一定要 先 首页 最先显示
 
UniTreeView1.FullExpand;

end;
 
procedure TMainForm.UniTreeView1Click(Sender: TObject);
var
  I: Integer;
begin
  for I := UniPageControl1.PageCount - 1 downto 0 do
  begin
    UniPageControl1.Pages[I].Visible := false;
    UniPageControl1.Pages[I].TabVisible := false;
  end;


  for I := UniPageControl1.PageCount - 1 downto 0 do  begin
    if UniPageControl1.Pages[I].Caption = UniTreeView1.Selected.Text then
    begin
      UniPageControl1.Pages[I].Visible := true;
      UniPageControl1.Pages[I].TabVisible := true;;
      break;
    end;
    UniPageControl1.Pages[0].TabVisible := true;
    UniPageControl1.Pages[0].Visible := true;
  end;

end;
procedure TMainForm.SearchTree(const AText: string);
var
  S, SString: string;
  I: Integer;
  aExpand: Boolean;
begin
  SString := Trim(AText);
  if SString <> PSString then
  begin
    PSString := LowerCase(SString);
    if (Length(PSString) > 0) or (PSString = '') then
    begin
      aExpand := PSString <> '';
      UniTreeView1.BeginUpdate;
      tryfor I := 0 to UniTreeView1.Items.Count - 1 do
        begin
          S := LowerCase(UniTreeView1.Items[I].Text);
          UniTreeView1.Items[I].Visible := (Length(PSString) = 0) or
            (Pos(PSString, S) > 0);
          UniTreeView1.Items[I].Expanded := aExpand;
        end;
      finally
        UniTreeView1.EndUpdate;
      end;
    end;
  end;
end;

源文件下载

 

你可能感兴趣的:(uniGUI之多页面框架(16))