LoginSignup
0
0

More than 3 years have passed since last update.

2015-12-09 c++ builder > LiveBinding > 1. 使用例と関連ファイルの中身

Last updated at Posted at 2015-12-08
動作確認
C++ Builder XE4

c++ builder > LiveBinding入門してみた
http://qiita.com/7of9/items/72cd03dcaa999ed6ea85


チュートリアル @ XE8

入門してみた

  • フォーム : Form1
  • ユニット : Unit1.cpp
  1. Edit1, Label1, ColorBox1をForm1に追加
  2. Form1上で右クリックで「ビジュアルにバインド」を選択
    • LiveBindingデザイナが開く

(この時に、Unit1.vlbファイルが以下の内容で生成された)

[Label1]
Coordinates=220,10,53,58

[ColorBox1]
Coordinates=127,10,74,58
Visible=True

[Edit1]
Coordinates=73,10,44,58

[]
Coordinates=175,1,91,36

次にLiveBindingデザイナで以下を行った。

  1. Edit1の"..."を選択し、「バインド可能なメンバ」にて"Color"を選択
    • Edit1にColorが追加される
  2. ColorBox1のSelectedからEdit1のColorへドラッグ
    • 両者のリンクが生成される

この段階でUnit.vlbファイルは以下のようになっている。

  • Edit1に ExplicitSubNodes=Color が追加
  • BindingsList1 が追加
Unit1.vlb
[Label1]
Coordinates=360,10,53,58

[ColorBox1]
Coordinates=210,10,74,58
Visible=True

[Edit1]
Coordinates=73,10,44,80
ExplicitSubNodes=Color

[]
Coordinates=175,1,91,36

[BindingsList1]
Coordinates=136,87,91,36

また、Unit1.dfmに以下が追加されている。

Unit1.dfm
  object BindingsList1: TBindingsList
    Methods = <>
    OutputConverters = <>
    Left = 20
    Top = 5
    object LinkControlToPropertyColor: TLinkControlToProperty
      Category = #12463#12452#12483#12463' '#12496#12452#12531#12487#12451#12531#12464
      Control = ColorBox1
      Track = True
      Component = Edit1
      ComponentProperty = 'Color'
    end
  end

Control = ColorBox1
Component = Edit1
ComponentProperty = Color
などからLiveBindingの動作が読み取れる。

実際にビルドして実行すると、ColorBox1を変更することで、Edit1の色を変更できる。

Label1に対しても同様にして色を変更できるようになる。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0