我是VB和视觉工作室的新手。我按照在线教程进行绑定。但我无法单击高级绑定页面的Text属性,如下所示。我不确定调试需要哪些信息。所以,我只是在这里发布了creenshot。任何问题。请告诉我。 用作数据源的类的代码:
Public Class MIConfig
Public m_name As String
Public m_primary As Integer
Public Sub New(ByVal name As String, ByVal primary As Integer)
m_name = name
m_primary = primary
End Sub
End Class
'TextBox1
'
Me.TextBox1.Location = New System.Drawing.Point(3, 193)
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.Size = New System.Drawing.Size(120, 26)
Me.TextBox1.TabIndex = 3
更新
为什么要投票,请留下评论或解决方案或其他任何内容? 否则,投票不能帮助改善社会。
答案 0 :(得分:0)
Advanced binding
(屏幕截图中的窗口) - > Binding
- > Add project DataSource
- > Object
- >选择你的班级Binding
中选择要用于数据绑定的类的属性
默认情况下,属性将限制为TextBox.Text属性对于数据绑定,您需要在类中拥有属性,此时您的类只包含字段
Public Class MIConfig
Public Property Name As String
Public Property Primary As Integer
Public Sub New(ByVal name As String, ByVal primary As Integer)
Me.Name = name
Me.Primary = primary
End Sub
End Class
如果您无法通过Designer使用数据绑定,请在代码中尝试
Public Class MyForm
Private _BindingModel As MIConfig
Public Sub New(model As MIConfig)
Me.InitializeComponent()
_BindingModel = model
TextBox1.DataBinding.Add("Text", _BindingModel, "m_name", True)
End Sub
End Class