Difference between revisions of "TGroupBox/ja"
From Lazarus wiki
Jump to navigationJump to search (→例) |
|||
(One intermediate revision by the same user not shown) | |||
Line 3: | Line 3: | ||
{{ Japanese Menu }} | {{ Japanese Menu }} | ||
− | + | '''TGroupBox'''は、[[image:tgroupbox.png]]フォーム上で物理的および概念的に複数のオブジェクトをグループ化するためのコンテナである。GroupBox内のコントロールは、関連する機能や情報をグループ化して表示するのに役立つ。 | |
− | == | + | ==使い方== |
− | + | フォーム上で[[doc:lcl/stdctrls/tgroupbox.html|TGroupBox]]を使用するには、単に[[Component Palette/ja|コンポーネントパレット]]の[[Standard tab/ja|Standardタブ]]からそれを選択し、フォーム上でクリックして配置する。GroupBoxは、関連するコントロールや情報を視覚的にグループ化するための便利なコンテナである。 | |
− | == | + | ==例== |
− | * | + | * 新しいアプリケーションを作成し、フォームに2つのTGroupBoxを配置 |
− | * | + | * GroupBox1には[[TButton/ja]]、''Button1''を、GroupBox2にはTButton、''Button2''を配置する。 |
− | * | + | * フォームの外側に[[TRadioButton/ja]]を2つ配置する。 |
− | * | + | * [[IDE_Window:_Object_Inspector/ja|オブジェクトインスペクタ]]で、RadioButton1のCaptionを''User''に、RadioButton2のCaptionを''Administrator''に変更する。 |
− | * | + | * RadioButton2のChecked[[Property/ja|property]]を''[[True]]''に設定する。 |
− | * | + | * RadioButton1をダブルクリックして、RadioButton1の''OnChange''[[Event handler|イベントハンドラ]]''を作成する。 |
− | * | + | * このハンドラをRadioButton2のOnChangeイベントにも割り当てる。 |
− | ** | + | ** オブジェクトインスペクタで、''RadioButton2''を選択する。 |
− | ** | + | ** オブジェクトインスペクタに移動し''Events'' を選択する。 |
− | ** | + | ** OnChangeイベントを選択し、隣接するコンボボックスで''RadioButton1Change''を選択する。 |
− | * | + | * ラジオボタンのイベントハンドラで、''GroupBox2''をユーザーから非表示にする。 |
− | ** | + | ** ソースエディタのRadioButtonのイベントハンドラに以下の行を記述する: |
<syntaxhighlight lang="Pascal"> | <syntaxhighlight lang="Pascal"> | ||
procedure TForm1.RadioButton1Change(Sender: TObject); | procedure TForm1.RadioButton1Change(Sender: TObject); | ||
Line 27: | Line 27: | ||
end; | end; | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | + | ボタンのイベントハンドラも追加し、以下のようなコードを追加する: | |
<syntaxhighlight lang="Pascal"> | <syntaxhighlight lang="Pascal"> | ||
procedure TForm1.Button1Click(Sender: TObject); | procedure TForm1.Button1Click(Sender: TObject); | ||
Line 33: | Line 33: | ||
ShowMessage('User and administrator can click this button'); | ShowMessage('User and administrator can click this button'); | ||
end; | end; | ||
− | |||
procedure TForm1.Button2Click(Sender: TObject); | procedure TForm1.Button2Click(Sender: TObject); | ||
begin | begin | ||
Line 39: | Line 38: | ||
end; | end; | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | * | + | * ボタンを押せる人を示す[[Dialog_Examples#ShowMessage|ShowMessage]]ダイアログに表示される。 |
− | * | + | * 実行すると以下のように見える: |
[[image:ExampleTGroupBox1.png]] -> [[image:ExampleTGroupBox2.png]] | [[image:ExampleTGroupBox1.png]] -> [[image:ExampleTGroupBox2.png]] |
Latest revision as of 09:05, 24 March 2024
│
Deutsch (de) │
English (en) │
suomi (fi) │
français (fr) │
日本語 (ja) │
русский (ru) │
TGroupBoxは、フォーム上で物理的および概念的に複数のオブジェクトをグループ化するためのコンテナである。GroupBox内のコントロールは、関連する機能や情報をグループ化して表示するのに役立つ。
使い方
フォーム上でTGroupBoxを使用するには、単にコンポーネントパレットのStandardタブからそれを選択し、フォーム上でクリックして配置する。GroupBoxは、関連するコントロールや情報を視覚的にグループ化するための便利なコンテナである。
例
- 新しいアプリケーションを作成し、フォームに2つのTGroupBoxを配置
- GroupBox1にはTButton/ja、Button1を、GroupBox2にはTButton、Button2を配置する。
- フォームの外側にTRadioButton/jaを2つ配置する。
- オブジェクトインスペクタで、RadioButton1のCaptionをUserに、RadioButton2のCaptionをAdministratorに変更する。
- RadioButton2のCheckedpropertyをTrueに設定する。
- RadioButton1をダブルクリックして、RadioButton1のOnChangeイベントハンドラを作成する。
- このハンドラをRadioButton2のOnChangeイベントにも割り当てる。
- オブジェクトインスペクタで、RadioButton2を選択する。
- オブジェクトインスペクタに移動しEvents を選択する。
- OnChangeイベントを選択し、隣接するコンボボックスでRadioButton1Changeを選択する。
- ラジオボタンのイベントハンドラで、GroupBox2をユーザーから非表示にする。
- ソースエディタのRadioButtonのイベントハンドラに以下の行を記述する:
procedure TForm1.RadioButton1Change(Sender: TObject);
begin
GroupBox2.Visible:=Radiobutton2.Checked;
end;
ボタンのイベントハンドラも追加し、以下のようなコードを追加する:
procedure TForm1.Button1Click(Sender: TObject);
begin
ShowMessage('User and administrator can click this button');
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
ShowMessage('Only administrator can click this button');
end;
- ボタンを押せる人を示すShowMessageダイアログに表示される。
- 実行すると以下のように見える:
See also