ItemTemplate에 Label1 및 Button1이있는 DataRepeater1이 있습니다. 이 세 개의 컨트롤은 BindingList (Of T)에 바인딩됩니다. 여기서 T는 atm이라는 단일 문자열 속성을 가진 매우 간단한 클래스입니다.바운드 데이터를 변경할 때 DataRepeater가 업데이트되지 않습니다.
사용자가 DataRepeater Item의 단추 중 하나를 클릭하면 바인딩 된 데이터의 문자열을 업데이트합니다 명부. I.E. 사용자가 DataRepeater에서 항목 0의 단추를 클릭하면 동일한 인덱스에있는 BindingList의 문자열이 변경됩니다.
이 작동하지 않습니다 무엇
문자열이 해당 문자열에 바인딩으로 관련 항목에 대한 Label1을 업데이트해야입니다 DataRepeater 변경 이후입니다 작동 -하지만하지 않습니다.
아무도 말해 줄 수 있습니까? 내 현재 코드는 아래와 같습니다. 감사합니다
Imports System.ComponentModel
Public Class Form1
Class ListType
Public Sub New(newString As String)
Me.MyString = newString
End Sub
Public Property MyString As String
End Class
Dim MyList As New BindingList(Of ListType)
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
' Bind BindingList to DataRepeater.
Label1.DataBindings.Add("Text", MyList, "MyString")
DataRepeater1.DataSource = MyList
' Add some items to the BindingList.
MyList.Add(New ListType("First"))
MyList.Add(New ListType("Second"))
MyList.Add(New ListType("Third"))
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
' Use the Index of the current item to change the string
' of the list item with the same index.
MyList(DataRepeater1.CurrentItemIndex).MyString = "Clicked"
' Show all the current list strings in a label outside of
' the DataRepeater.
Label2.Text = String.Empty
For Each Item As ListType In MyList
Label2.Text = Label2.Text & vbNewLine & Item.MyString
Next
End Sub
End Class
"이 링크는 질문에 대한 대답 일지 모르지만 여기에 답변의 핵심 부분을 포함하고 참조 용 링크를 제공하는 것이 좋습니다. 링크 된 페이지가" – zero323
@ zero323 : INotifyPropertyChnaged를 사용하는 방법에 대한 해답을 업데이트했습니다. 감사. –