TRadioGroup/ja: what changed
Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.
Title: TRadioGroup/ja
| Old | New | Line | |
|---|---|---|---|
| 1 | + | TRadioGroupは、関連するが相互に排他的な[[TRadioButton/ja|TRadioButtonのグループであり]]、ユーザーに対して選択肢の1つを選択する必要がある。それは、統合された[[TRadioButton/ja|TRadioButtonsを]]持つ[[TGroupBox/ja|TGroupBoxのようなものである]]。 | |
| 2 | + | ||
| 3 | + | ## 使い方 | |
| 4 | + | ||
| 5 | + | [[TForm|FormでTRadioGroupを]]使用するには、単純に[[Component Palette/ja|Componentパレットの]][[Standard tab/ja|Standardタブでそれを]]選択し、フォームをクリックして配置します。 | |
| 6 | + | ||
| 7 | + | ### 例 | |
| 8 | + | ||
| 9 | + | ジオメトリック図形は、TRadioGroupによってフォームにランダムに描画され、表示される。最初のRadioGroupは図形を決定し、2番目のRadioGroupは個数を決定する。 | |
| 10 | + | ||
| 11 | + | - 新しいアプリケーションを作成し、フォームに2つのTRadioGroupを配置する。 | |
| 12 | + | - オブジェクトインスペクタで、*RadioGroup1*の*Name*プロパティを*rgShape*に、*RadioGroup2*の*Name*プロパティを*rgCount*に変更する。 | |
| 13 | + | - *rgShape*の*Caption*を*Shape*に、*rgCount*の*Caption*を*Count*に変更する。 | |
| 14 | + | - *rgShape*のためのラジオボタンを追加する: | |
| 15 | + | - オブジェクトインスペクタで、*rgShape*の*Items*プロパティを選択する。 | |
| 16 | + | - \[...\]ボタンをクリックすると、文字列エディタが開く。 | |
| 17 | + | - それぞれ*Lines*, *Rectangles*, *Ellipses*と入力し、*OK*ボタンをクリックしてエントリを完了する。 | |
| 18 | + | - *rgCount*のためにも同様にラジオボタンを追加する(以下のように入力)1、5、10、20、50、100 | |
| 19 | + | - *rgShape*と*rgCount*の*ItemIndex*プロパティをそれぞれ*-1*から*0*に設定して、最初のRadioButtonを*currently selected*にする。 | |
| 20 | + | - *rgShape*をダブルクリックして、*rgShape*の*OnClick*イベントハンドラを作成する。 | |
| 21 | + | - 同じイベントハンドラを*rgCount*にも使用する。 | |
| 22 | + | - オブジェクトインスペクタで*rgCount*を選択する。 | |
| 23 | + | - ここで、オブジェクトインスペクタで*Events*タブを選択してください。 | |
| 24 | + | - *OnClick*イベントに移動し、隣のコンボボックスで*rgShapeClick*を選択する。 | |
| 25 | + | - *rgShape*または*rgCount*がクリックされるたびに、フォームが再描画されるようにするために、次のコードをイベントハンドラに記述する: | |
| 26 | + | ||
| 27 | + | ``` pascal | |
| 28 | + | procedure TForm1.rgShapeClick(Sender: TObject); | |
| 29 | + | begin | |
| 30 | + | Repaint; | |
| 31 | + | end; | |
| 32 | + | ``` | |
| 33 | + | ||
| 34 | + | - フォームが再描画されるたびに、図形を描画する必要がある。 | |
| 35 | + | - オブジェクトインスペクタで *Form1* を選択する。 | |
| 36 | + | - *Events*タブを選択する。 | |
| 37 | + | - *OnPaint*イベントの横にある \[...\] ボタンをクリックする。 | |
| 38 | + | - ハンドラが作成される。以下のコードを入力する: | |
| 39 | + | ||
| 40 | + | ``` pascal | |
| 41 | + | procedure TForm1.FormPaint(Sender: TObject); | |
| 42 | + | var | |
| 43 | + | i: Integer; | |
| 44 | + | begin | |
| 45 | + | if TryStrToInt(rgCount.Items[rgCount.ItemIndex], i) then | |
| 46 | + | for i:=1 to i do begin | |
| 47 | + | Canvas.Pen.Color:=Random($1000000); | |
| 48 | + | Canvas.Brush.Color:=Random($1000000); | |
| 49 | + | case rgShape.Items[rgShape.ItemIndex] of | |
| 50 | + | 'Lines': Canvas.Line(Random(ClientWidth), Random(ClientHeight), Random(ClientWidth), Random(ClientHeight)); | |
| 51 | + | 'Rectangles': Canvas.Rectangle(Random(ClientWidth), Random(ClientHeight), Random(ClientWidth), Random(ClientHeight)); | |
| 52 | + | 'Ellipses': Canvas.Ellipse(Random(ClientWidth), Random(ClientHeight), Random(ClientWidth), Random(ClientHeight)); | |
| 53 | + | end; | |
| 54 | + | end; | |
| 55 | + | end; | |
| 56 | + | ``` | |
| 57 | + | ||
| 58 | + | - プログラムを実行すると、以下のように見えるだろう: | |
| 59 | + | ||
| 60 | + | <figure> | |
| 61 | + | <img src="ExampleTRadioGroup.png" title="ExampleTRadioGroup.png" /> | |
| 62 | + | <figcaption>ExampleTRadioGroup.png</figcaption> | |
| 63 | + | </figure> | |
| 64 | + | ||
| 65 | + | ## 以下も参照のこと | |
| 66 | + | ||
| 67 | + | - [[doc:lcl/extctrls/tradiogroup.html|TRadioGroup doc]] | |
| 68 | + | - [[TRadioButton/ja]] | |
| 69 | + | - [[TGroupBox/ja]] | |
| 70 | + | ||
| 71 | + | --- | |
| 72 | + | *From the Free Pascal wiki, page "TRadioGroup/ja", as it stood on 2024-03-24 after a change by Ariben, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).* |
