属性selecteditem只读取RadioButtonList

时间:2016-03-28 11:40:21

标签: vb.net winforms user-interface properties radio-button

当我动态创建这样的单选按钮列表时,我有错误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创建一个用户选择项目的表,但我希望某个按钮具有预先选择的值并且不显示。当我阅读所有选中的按钮时,我希望这样。

1 个答案:

答案 0 :(得分:1)

您的问题是,在尝试选择control之前,您无法看到true

将这些更改为DDL.Visible = False RBL.Visible = False CBL.Visible = False

radio button

最重要的是,当时在control内只能选择一个DDL.SelectedItem = True RBL.SelectedItem = True CBL.SelectedItem = True ,所以这有点毫无意义:

Dim DDL As New DropDownList

更新

Dim RBL As New RadioButtonList

以上无法检查

controls

我相信首先会被检查

我刚刚意识到你试图创建这些controls。在实际add之前,您无法检查,取消选中public void MainHistory{ @SerializedName("Status") private String status; @SerializedName("History") private List<ChildHistory> history; //getters and setters } 。这link可以帮助您