簡體   English   中英

Delphi:TCoolBar + TToolBar+TEdit+TCheckBox

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

如何將 ToolBar 放在 CoolBar 的左側,Edit - center,CheckBox - 在右側?

我試圖在 2 小時內做到這一點,但我做不到:(控件落后於其他控件,或者具有 CoolBar 的寬度。愚蠢的事情:)

在此處輸入圖像描述

謝謝!

你的設計應該是什么樣子的截圖會有所幫助,但將它們放在單獨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

我認為您正在搜索 CoolBand 的Break屬性:

Break 屬性 (TCoolBand)使帶區從新行開始。 如果 Break 為真(默認值),則帶區在 TCoolBar 控件的左側開始一個新行。 如果 Break 為 false,則帶區繼續沿與其前身相同的行。

因此,獲取圖像布局的步驟:

  • 在表單上放一個 CoolBar(默認頂部對齊)並給它一些額外的高度,
  • 將 FixedOrder 設置為 True,將 ToolBar、Edit 和 CheckBox 添加到 CoolBar,
  • 打開樂隊收藏編輯器,
  • 將每個 CoolBand 集合項的 Break 屬性設置為 False,
  • 拖動獨立CoolBands的寬度(或設置每個的width屬性),
  • 將 CoolBar.AutoSize 設置為 True。

在此處輸入圖像描述

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM