uniGUI之多頁面框架(16)

效果圖:spa

 

 

 左邊的樹 的樹結點 ,經過 結點名 與 右 側TabSheet名 一致時,顯示 相關頁面。設計

這是相關 源代碼3d

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;
      try
        UniTreeView1.ResetData;
        for 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;

源文件下載code

相關文章
相關標籤/搜索