我想在表單中有一個標籤,其文本值根據類實例的值而變化。它看起來像我可以將標籤的文本值綁定到對象dataSource。當我嘗試它時,它似乎不起作用。將VB.NET label.text綁定到對象屬性
Me.Label4.DataBindings.Add(New System.Windows.Forms.Binding("Text", Me.ItemInfoBindingSource, "ItemNumber", True, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged))
我itemInfoBindingSource:
Me.ItemInfoBindingSource.DataSource = GetType(CFP.ItemInfo)
和類定義:
Public Class ItemInfo
Public Property ItemNumber As String = "rename"
Public Property Description As String
Public Property FileLocation As String
Public Property CompileHistory As List(Of CompileHistory)
End Class
我想我所做的是綁定到類,而不是一個類的實例。考慮一下,我真正想要做的是將一個類的實例綁定到一個標籤上......如何? 這可能嗎?
謝謝!正是我今天所期待的。 – thephez