VS 2010 Radiobutton and textbox-VBForums
Results 1 to 9 of 9

Thread: Radiobutton and textbox

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2010
    Posts
    130

    Radiobutton and textbox

    How can I do once I click on "textbox.text" This will select on RadioButton?

  2. #2
    Wait... what? weirddemon's Avatar
    Join Date
    Jan 2009
    Location
    USA
    Posts
    3,827

    Re: Radiobutton and textbox

    What?

    Are you asking if the user click on a specific TextBox, then the corresponding RadioButton will be checked?

    If so, handle the TextBox's Clicked event and call .Checked = True on the appropriate RadioButton.

    If not, you'll need to be more clear.
    CodeBank contributions: Process Manager, Temp File Cleaner

    Quote Originally Posted by SJWhiteley
    "game trainer" is the same as calling the act of robbing a bank "wealth redistribution"....

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Aug 2010
    Posts
    130

    Re: Radiobutton and textbox

    i try this:
    vb Code:
    1. If TextBox1.SelectedText = True Then
    2.             RadioButton2.Checked = True

    What is missing? (It does not display me an error but it does not work)

  4. #4
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    88,585

    Re: Radiobutton and textbox

    For us to know why your code isn't doing what you intended, we'd have to know what you intended. That's far from obvious from your code, which doesn't really make sense. In future, please take the time to post a FULL and CLEAR description of the problem. Posting a code snippet and saying it doesn't work doesn't qualify.

    As for the problem, I suggest that you start by reading the documentation for the TextBox.SelectedText property. The fact that you're comparing it to a Boolean value shows that what you think it does is not what it actually does. The SelectedText property returns the part of the Text that is selected. For instance, if you type "Hello" into a TextBox and then use the mouse to highlight just the two Ls, SelectedText will return the part of the Text that is selected, i.e. "ll". If no text is highlighted then SelectedText will be an empty string. Regardless, it's a String, not a Boolean.

    2007-2014

    Why is my data not saved to my database? | MSDN Data Walkthroughs
    MSDN "How Do I?" Videos: VB | C#
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts) | WP8 Turnstile Feather Transition with Pivot Control
    Beginner Tutorials: VB | C# | SQL

  5. #5
    New Member Xscapism's Avatar
    Join Date
    Aug 2010
    Posts
    9

    Re: Radiobutton and textbox

    Your question isn't clear. But as far as I can understand you want to check the radiobutton when you click the textbox.

    Add this to your code:

    Code:
    Private Sub TextBox1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox1.Click
    RadioButton1.Checked=True
    End Sub
    If this isn't what you want then, then please explain your problem correctly.

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Aug 2010
    Posts
    130

    Re: Radiobutton and textbox

    sory my english is bad
    just want to do I click on my textbox1.text and This will select a radio button


  7. #7
    New Member Xscapism's Avatar
    Join Date
    Aug 2010
    Posts
    9

    Re: Radiobutton and textbox

    Quote Originally Posted by OR444 View Post
    sory my english is bad
    just want to do I click on my textbox1.text and This will select a radio button

    I already posted the solution in my previous post. Anyways here's it again. Add this to your code.

    Code:
    Private Sub TextBox1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox1.Click
    RadioButton1.Checked=True
    End Sub

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    Aug 2010
    Posts
    130

    Re: Radiobutton and textbox

    Quote Originally Posted by Xscapism View Post
    I already posted the solution in my previous post. Anyways here's it again. Add this to your code.

    Code:
    Private Sub TextBox1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox1.Click
    RadioButton1.Checked=True
    End Sub
    Sorry
    thanks a lot .. Works great!

  9. #9

    Thread Starter
    Addicted Member
    Join Date
    Aug 2010
    Posts
    130

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.