【发布时间】:2015-09-23 14:59:35
【问题描述】:
我正在运行 Visual Studio 2015 的社区版。
我正在尝试使用Me.Controls...CheckState = CheckState.Unchecked 动态更改动态创建的复选框的 CheckState 属性,但我收到一个编译时错误,指出 CheckState 不是控件的成员。
我在下面显示了我用来创建复选框的代码,在底部显示了我试图用来更改值的代码。如有任何建议,我将不胜感激。
cbPDF.Location = New Point(710, tvposition)
cbPDF.Size = New Size(80, 20)
cbPDF.Name = "cbPDF" + panposition.ToString
cbPDF.Text = "PDF Conv"
cbPDF.CheckState = CheckState.Unchecked
Controls.Add(cbPDF)
AddHandler cbPDF.CheckedChanged, AddressOf Me.CommonCheck
arrTextVals(10, panposition) = "cbPDF" + panposition.ToString
arrTextVals(11, panposition) = "unchecked"
If arrTextVals(11, bottomLine) = "unchecked" Then
Me.Controls(arrTextVals(10, bottomLine)).CheckState = CheckState.Unchecked
Else
Me.Controls(arrTextVals(10, bottomLine)).CheckState = CheckState.Checked
End If
【问题讨论】:
-
Control 是基类,就像它说它没有那个成员一样。将其转换为 CheckBox 然后调用它。
标签: .net vb.net visual-studio checkbox controls