简体   繁体   English

Delphi:TCoolBar + TToolBar+TEdit+TCheckBox

[英]Delphi: TCoolBar + TToolBar+TEdit+TCheckBox

How can I put ToolBar on the left side of CoolBar, Edit - center, CheckBox - on the right?如何将 ToolBar 放在 CoolBar 的左侧,Edit - center,CheckBox - 在右侧?

I am trying to do this during 2 hours and I can not:( Controls are behind others, or have a width as CoolBar. Stupid things:)我试图在 2 小时内做到这一点,但我做不到:(控件落后于其他控件,或者具有 CoolBar 的宽度。愚蠢的事情:)

在此处输入图像描述

Thanks!谢谢!

A screenshot of what your design should look like would help but placing them on seperate TPanels gives you more freedom sort to speak.你的设计应该是什么样子的截图会有所帮助,但将它们放在单独TPanels上会给你更多的自由发言权。

.pas File .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 File .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

I think you are searching for the Break property of a CoolBand:我认为您正在搜索 CoolBand 的Break属性:

Break property (TCoolBand) causes the band to start on a new line. Break 属性 (TCoolBand)使带区从新行开始。 If Break is true (the default), the band starts a new line at the left side of the TCoolBar control.如果 Break 为真(默认值),则带区在 TCoolBar 控件的左侧开始一个新行。 If Break is false, the band continues on the same line as its predecessor.如果 Break 为 false,则带区继续沿与其前身相同的行。

So the steps to get the layout of your image:因此,获取图像布局的步骤:

  • Put a CoolBar on the form (default top aligned) and give it some extra height,在表单上放一个 CoolBar(默认顶部对齐)并给它一些额外的高度,
  • Set FixedOrder to True, Add a ToolBar, an Edit and a CheckBox to the CoolBar,将 FixedOrder 设置为 True,将 ToolBar、Edit 和 CheckBox 添加到 CoolBar,
  • Open the bands collection editor,打开乐队收藏编辑器,
  • Set of every CoolBand collection item the Break property to False,将每个 CoolBand 集合项的 Break 属性设置为 False,
  • Drag the width of the independent CoolBands (or set the width property of each),拖动独立CoolBands的宽度(或设置每个的width属性),
  • Set CoolBar.AutoSize to True.将 CoolBar.AutoSize 设置为 True。

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM