2011-11-18 10 views
0

私はC#の初心者で、データバインディングについて読んでいます。私の本は、次のような開始コードを導入しています。C#のデータバインディング、このコードは何をしていますか?

// Create object (width, text, color) 

TextParms tp = new TextParms(200, "Casablanca", Color.Beige); 

// Bind text and BackColor properties of control 

txtMovie.DataBindings.Add("Text", tp, "Tb_Text"); // line 2 

line 2は実際に何をしていますか?パラメータTextTb_Textはどこから来たのですか?その用途は何ですか?

答えて

1

txtMovie.DataBindings.Add("Text", tp, "Tb_Text")

Binding

のドキュメントを見てみます​​
  • テキスト
  • Tb_TextがあなたのTextParamsクラスのデータメンバーであるあなたのデータバインディングのソースあなたのTPでおそらくあなたのtxtMovieオブジェクト
  • データソースの財産です。
1

http://msdn.microsoft.com/en-us/library/b6y3aby2.aspx

public Binding Add(
    string propertyName, 
    Object dataSource, 
    string dataMember 
) 

パラメータ:

_propertyName_ 
Type: System.String 
The name of the control property to bind. 

_dataSource_ 
Type: System.Object 
An Object that represents the data source. 

_dataMember_ 
Type: System.String 
The property or list to bind to. 
+0

私の質問は「_propertyName_」と「_dataMember_」の両方の名前はユーザー定義ですか? –

+1

私はそれほど多くのデータバインディングを扱っていませんが、データソースの 'Tb_Text'カラムを' txtMovie'コントロールの 'Text'プロパティにバインドしていると思います。 – CodeCaster

関連する問題