zoukankan      html  css  js  c++  java
  • Delphi动态添加控件

    {动态添加导航}
    var
    Panl:Tpanel;
    MainPage,Subpage:TPageControl;
    TabSheet1: TTabSheet;
    ToolBar2: TToolBar;
    Splitter:TSplitter;
    begin
    {创建导航树开始}
     Panl:=Tpanel.Create(self);
     with Panl  do
     begin
        Parent := mainForm;
        Left:= 0 ;
        Top:= 30  ;
        Width:= 185 ;
        Height:= 381 ;
        Align:= alLeft;
        Caption:= 'Panel1';
        TabOrder:= 2;
      end;
      {创建导航树结束}
    
            MainPage:=TPageControl.Create(self);
            with MainPage do
            begin
            Parent := Panl;
                Left := 0;
                Top := 0;
                Width := 235;
                Height := 410;
                ActivePage := TabSheet1;
                Align := alClient;
                BiDiMode := bdLeftToRight;
                Font.Charset := DEFAULT_CHARSET;
                Font.Color := clWindowText;
                Font.Height := -13;
                Font.Name := 'MS Sans Serif';
                Font.Style := [];
                MultiLine := True;
                ParentBiDiMode := False;
                ParentFont := False;
                TabOrder := 0;
                TabPosition := tpLeft;
             end;
             TabSheet1:=TTabSheet.Create(self);
             TabSheet1.Parent := MainPage;
             TabSheet1.Caption := '树形导航';
    
             ToolBar2:=TToolBar.Create(self);
    
            with ToolBar2 do
            begin
            Parent :=TabSheet1;
                    Left := 0;
                    Top := 0;
                    Width := 207;
                    Height := 30;
                    ButtonHeight := 28;
                    ButtonWidth := 29;
                    Caption := 'ToolBar2';
                    EdgeInner := esNone;
                    EdgeOuter := esNone;
                    Flat := True;
                    Images := ImageList1;
                    TabOrder := 0;
                    TabStop := True;
                    Wrapable := False;
            end;
    
      {添加分割条开始}
      Splitter:=TSplitter.Create(self);
      with Splitter  do
      begin
        Parent := mainForm;
        Left := 185;
        Top := 30;
        Height:= 381;
      end;
      {添加分割条结束}
    end;
    View Code

    delphi 动态创建菜单

    delphi 动态创建菜单
    
    procedure TForm1.Button1Click(Sender: TObject);
    var
    MainMenu:TMainMenu;
    MenuItem:TMenuItem;
    begin
    //创建主菜单对象,并设置主窗口的菜单为MainMenu对象
    MainMenu:=TMainMenu.Create(Self);
    Self.Menu:=MainMenu;
    
    //创建MainMenu主菜单的第一级菜单对象 MainMenu.Items.Add
    MenuItem:=TMenuItem.Create(MainMenu);
    MenuItem.Caption:='一级菜单';
    MainMenu.Items.Add(MenuItem);
    
    //创建MainMenu主菜单的第二级子菜单对象 MainMenu.Items[0].Add
    MenuItem:=TMenuItem.Create(MainMenu);
    MenuItem.Caption:='二级菜单';
    MainMenu.Items[0].Add(MenuItem);
    
    //创建MainMenu主菜单的第三级子菜单对象 MainMenu.Items[0].Items[0].Add
    MenuItem:=TMenuItem.Create(MainMenu);
    MenuItem.Caption:='三级菜单';
    MainMenu.Items[0].Items[0].Add(MenuItem);
    
    // 用Items[0]...这种形式,可以创建 四级、五级直到N级菜单都可以
    
    MenuItem:=TMenuItem.Create(MainMenu);
    MenuItem.Caption:='四级菜单';
    MainMenu.Items[0].Items[0].Items[0].Add(MenuItem);
    
    end;
  • 相关阅读:
    算法导论4线性时间与暴力寻找最大子数组
    算法导论4.1DivideAndConquer寻找最大子数组
    算法导论2.3算法设计分治法合并排序
    算法导论第二章算法入门2.1 插入排序
    eclipse 从已经存在代码建工程
    centos6.3 eclipse cdt
    Cant open file /data/svn/dev/db/txn-current-lock: Permission denied的解决方法
    git命令的安装与github简单使用
    CentOS-6.3安装配置SVN
    github使用_转
  • 原文地址:https://www.cnblogs.com/blogpro/p/11453462.html
Copyright © 2011-2022 走看看