Вопрос

I have an INI file that stores the selected radio box on exit. It's like:

[Settings] SearchWhat=RadioButtonName

When my form loads I am wanting to take that name and set it as checked. I tried:

 Dim searchwhat = ini.ReadValue("settings", "searchwhat")
 searchwhat.checked = True

But that returns the error: checked' is not a member of 'String'

That INI function gives the value but I can't figure out to "make it true"

MTIA

Это было полезно?

Решение

Use the Controls.Find() function like this:

Dim searchwhat As String = ini.ReadValue("settings", "searchwhat")
Dim matches() As Control = Me.Controls.Find(searchwhat, True)
If matches.Length > 0 AndAlso TypeOf matches(0) Is RadioButton Then
    Dim rb As RadioButton = DirectCast(matches(0), RadioButton)
    rb.Checked = True
End If
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top