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 4 Years Ago by iFrolox

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.

Comments
Yea, its what i had to do.

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
Comments
Thank you for providing the code
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.