Delphi:TCoolBar + TToolBar + TEdit + TCheckBox

时间:2011-07-01 03:14:09

标签: delphi toolbar edit

如何将ToolBar放在CoolBar左侧,编辑 - 中心,CheckBox - 右侧?

我试图在2小时内做到这一点我不能:(控件落后于其他人,或者宽度为CoolBar。愚蠢的事情:)

enter image description here

谢谢!

2 个答案:

答案 0 :(得分:4)

您的设计应该是什么样子的屏幕截图会有所帮助,但是将它们放在单独的TPanels上会让您有更多的自由来说话。

.pas文件

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ComCtrls, StdCtrls, ToolWin, ExtCtrls;

type
  TForm1 = class(TForm)
    Panel1: TPanel;
    CoolBar1: TCoolBar;
    Panel2: TPanel;
    tlb1: TToolBar;
    Edit1: TEdit;
    CheckBox1: TCheckBox;
    btnToolbar: TToolButton;
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

end.

.dfm文件

object Form1: TForm1
  Left = 0
  Top = 0
  Caption = 'Form1'
  ClientHeight = 348
  ClientWidth = 643
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'Tahoma'
  Font.Style = []
  OldCreateOrder = False
  PixelsPerInch = 96
  TextHeight = 13
  object Panel1: TPanel
    Left = 0
    Top = 0
    Width = 348
    Height = 348
    Align = alLeft
    Caption = 'Panel1'
    TabOrder = 0
    ExplicitLeft = 458
    ExplicitHeight = 185
    object CoolBar1: TCoolBar
      Left = 1
      Top = 1
      Width = 346
      Height = 75
      Bands = <>
      ExplicitLeft = 96
      ExplicitTop = 136
      ExplicitWidth = 150
    end
  end
  object Panel2: TPanel
    Left = 348
    Top = 0
    Width = 295
    Height = 348
    Align = alClient
    Caption = 'Panel2'
    TabOrder = 1
    ExplicitLeft = 432
    ExplicitTop = 128
    ExplicitWidth = 185
    ExplicitHeight = 41
    object tlb1: TToolBar
      Left = 1
      Top = 1
      Width = 293
      Height = 29
      Caption = 'tlb1'
      TabOrder = 0
      ExplicitLeft = 72
      ExplicitTop = 160
      ExplicitWidth = 150
      object btnToolbar: TToolButton
        Left = 0
        Top = 0
        Caption = 'btnToolbar'
        ImageIndex = 0
      end
    end
    object CheckBox1: TCheckBox
      Left = 80
      Top = 166
      Width = 97
      Height = 17
      Caption = 'CheckBox1'
      TabOrder = 1
    end
  end
  object Edit1: TEdit
    Left = 280
    Top = 164
    Width = 121
    Height = 21
    TabOrder = 2
    Text = 'Edit1'
  end
end

答案 1 :(得分:2)

我认为您正在搜索CoolBand的Break属性:

  

中断属性(TCoolBand)会导致频段在新行上开始。如果Break为true(默认值),则波段在TCoolBar控件的左侧开始一个新行。如果Break为false,则乐队将继续与其前任相同的行。

所以获得图像布局的步骤:

  • 在表单上放置一个CoolBar(默认顶部对齐)并给它一些额外的高度,
  • 将FixedOrder设为True, 将一个ToolBar,一个Edit和一个CheckBox添加到CoolBar,
  • 打开乐队收藏编辑器,
  • 将每个CoolBand集合项的Break属性设置为False,
  • 拖动独立CoolBands的宽度(或设置每个CoolBands的width属性),
  • 将CoolBar.AutoSize设置为True。

enter image description here