0
            If My.Forms.Main_frm.UseProxy.Checked = True Then
                My.Forms.Main_frm.IPBindingTextbox.Enabled = True
                My.Forms.Main_frm.ProxyIPTextbox.Enabled = True
                My.Forms.Main_frm.SocksV4.Enabled = True
                My.Forms.Main_frm.SocksV5.Enabled = True
                My.Forms.Main_frm.ProxyUser.Enabled = True
                My.Forms.Main_frm.ProxyPw.Enabled = True
            ElseIf My.Forms.Main_frm.UseProxy.Checked = False Then
                My.Forms.Main_frm.IPBindingTextbox.Enabled = False
                My.Forms.Main_frm.ProxyIPTextbox.Enabled = False
                My.Forms.Main_frm.SocksV4.Enabled = False
                My.Forms.Main_frm.SocksV5.Enabled = False
                My.Forms.Main_frm.ProxyUser.Enabled = False
                My.Forms.Main_frm.ProxyPw.Enabled = False
            End If

Is there a better way to do that? (By better i mean same result and less lines)

Edited by iFrolox

3
Contributors
3
Replies
5
Views
4 Years
Discussion Span
Last Post by iFrolox
Featured Replies
  • 1

    Put the controls you are enabling/disabling in a container control (panel or group) if possible. Then just enable or disable that one. The child controls will be enabled/disabled as well. Read More

  • Or if you can't or don't want to group the controls, set the Tag property of each to some known value then test in a loop like For Each ctrl As Control In Me.Controls If ctrl.Tag = "my value" Then ctrl.Enabled = True End If Next Read More

1

Put the controls you are enabling/disabling in a container control (panel or group) if possible. Then just enable or disable that one. The child controls will be enabled/disabled as well.

Votes + Comments
Yea, its what i had to do.
1

Or if you can't or don't want to group the controls, set the Tag property of each to some known value then test in a loop like

For Each ctrl As Control In Me.Controls
    If ctrl.Tag = "my value" Then
        ctrl.Enabled = True
    End If
Next
Votes + Comments
Thank you for providing the code
0
For Each phControl As Control In My.Forms.Main_frm.PhGroupBox1.Controls
    If phControl.Tag = "SocksTag" Then
       phControl.Enabled = Not phControl.Enabled
    End If
Next

Thank you, way faster and shorter :)
Voting and Solved

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.