how to disable textbox when click on radiobutton using VB script on Visual Studio.Net

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • hidayu1986
    New Member
    • Mar 2010
    • 7

    how to disable textbox when click on radiobutton using VB script on Visual Studio.Net

    how to disable textbox when click on radiobutton using VB script on Visual Studio.Net 2005.

    currently i used this coding but it is not functioning.


    Code:
    Private sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged
    
            If RadioButton1.Checked Then
                Me.textBox1.Visible = True
            Else
                Me.textBox1.Visible = False
            End If
        End Sub
    Last edited by tlhintoq; Mar 11 '10, 02:02 AM. Reason: [CODE] ...Your code goes between code tags [/CODE]
  • tlhintoq
    Recognized Expert Specialist
    • Mar 2008
    • 3532

    #2
    TIP: When you are writing your question, there is a button on the tool bar that wraps the [code] tags around your copy/pasted code. It helps a bunch. Its the button with a '#' on it. More on tags. They're cool. Check'em out.

    Comment

    • tlhintoq
      Recognized Expert Specialist
      • Mar 2008
      • 3532

      #3
      I might suggest something a bit more... smooth.

      Code:
      Private sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged
       
      Me.textBox1.Visible = RadioButton1.Checked
      
          End Sub
      The right side of an equasion is evaluated before the left.
      Thus if RadioButton1.Ch ecked evaluates to true, then me.textBox1.Vis ible is set to true.

      Comment

      • hidayu1986
        New Member
        • Mar 2010
        • 7

        #4
        thank u very much for your tips and your code suggestion. i already try it but it still the same not functioning when i click on radiobutton, the text box still not visible

        Comment

        • tlhintoq
          Recognized Expert Specialist
          • Mar 2008
          • 3532

          #5
          Then you aren't running the code. It's that simple.

          Are you sure you have assigned this method as the event handler to the control?

          Have you put a breakpoint in (at line 3) to watch the code break on this line, to ensure it is being executed?

          Comment

          • hidayu1986
            New Member
            • Mar 2010
            • 7

            #6
            i already try this code. is it that you mean?


            Private Sub RadioButton1_Ch eckedChanged(By Val sender As System.Object, ByVal e As System.EventArg s) Handles RadioButton1.Ch eckedChanged
            Me.TextBox3.Vis ible = RadioButton1.Ch ecked
            End Sub
            End Class

            Comment

            Working...