2011-11-18 2 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

의 문서를 보면
public Binding(
    string propertyName, 
    Object dataSource, 
    string dataMember 
) 
  • 텍스트
  • Tb_Text이 TextParams 클래스의 DataMember를 당신의 데이터 바인딩의 소스 당신의 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

DataBindings를 많이 사용하지는 않았지만 데이터 소스의'Tb_Text' 열을'txtMovie' 컨트롤의'Text' 속성에 바인딩하는 것 같습니다. – CodeCaster

관련 문제