【发布时间】:2016-07-15 16:00:35
【问题描述】:
当我像这样动态创建单选按钮列表时出现错误Property selecteditem is readonly:
Dim DDL As New DropDownList
Dim RBL As New RadioButtonList
Dim CBL As New CheckBoxList
DDL.ID = "DDL_" & SelectedCategory & "_" & SubAssy & "_" & ProductType
RBL.ID = "RBL_" & SelectedCategory & "_" & SubAssy & "_" & ProductType
CBL.ID = "CBL_" & SelectedCategory & "_" & SubAssy & "_" & ProductType
If ProductType = "General" Or (CategorySelected = "KC 2.1 (retractor without webbing)" And ProductType = "KC2.1" Or ProductType = "Webbing") Or
(CategorySelected = "KC 2.1 Seatbelt)" And ProductType = "KC2.1") Then
DDL.Visible = False
RBL.Visible = False
CBL.Visible = False
DDL.SelectedItem = True
RBL.SelectedItem = True
CBL.SelectedItem = True
End If
在这 3 行代码中:
DDL.SelectedItem = True
RBL.SelectedItem = True
CBL.SelectedItem = True
显示错误。我必须使用 RadioButtonList 或 DropDownList 或 CheckBoxList 创建一个表,用户在其中选择项目,但我希望某些按钮具有预选值并且不显示。当我阅读所有选择的按钮时,我想要它。
【问题讨论】:
-
A RadioButtonList 适用于 ASP.NET,但您的问题被标记为“winforms”。您实际使用的是哪一个?
-
已编辑,我要vb.net表格
-
SelectedItem是当前选择的哪个项。您不能将其设置为布尔值。我建议您阅读文档:msdn.microsoft.com/en-us/library/… -
好的,我明白,但我是如何检查我的价值的?
-
SelectedItem.Selected = True?或RBL.Items(item index).Selected = True.
标签: vb.net winforms user-interface properties radio-button