我有错误Property selecteditem is readonly
当我动态创建一个单选按钮,列表如下:物业将selectedItem是只读的单选按钮列表
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创建一个表,其中用户选择项目,但我希望某个按钮具有预选值并且不显示。当我阅读所有选中的按钮时,我都希望这一点。
一个RadioButtonList是ASP.NET的,但你的问题被标记为“winforms”。你实际使用哪一个? –
已被编辑,我想为vb.net表格 – Vladut
'SelectedItem'是当前选中的_which_项目。您不能将其设置为布尔值。我建议你阅读文档:https://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.listcontrol.selecteditem(v=vs.110).aspx –