Results 1 to 5 of 5

Thread: Seemingly Simple Problem [RESOLVED]

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Nov 2003
    Location
    Chicagoland
    Posts
    92

    Seemingly Simple Problem [RESOLVED]

    I have a form with some textboxes and radio buttons that enters data into a database. Often I need to enter sets of very similar data consecutively, like only a radio button needs to be changed for the next set of data, or the data in a single textbox is changed. Therefore, I don't clear the contents of the form once one set of data is submitted since it is easier to just tab to the proper control and change it rather than re-entering duplicate information.

    The problem - well, more of an annoyance, really - is that when I tab to the textboxes, the contents aren't highlighted so I can just start over typing what is there. I know I can just do Shift+End and highlight the whole box, but I _SHOULDN'T_ have to, gosh darnit.

    What irks me even more is that one of the textboxes is for a date and I have the form load event put today's date in there for me. When I tab to this textbox, it does get highlighted, as long as I don't change the date.

    How do I get the rest of my textboxes to highlight on subsequent tabs? Is there a property or something?
    Last edited by shadowfyre; Jun 3rd, 2004 at 11:03 AM.

  2. #2
    Member
    Join Date
    Apr 2004
    Posts
    44
    you can use the selectall() property

    Code:
          Private Sub textbox_TB_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles textbox_TB.Click
            textbox_TB.SelectAll()
        End Sub
    is that what you needed?

  3. #3
    PowerPoster
    Join Date
    Dec 2003
    Location
    Bristol, England (but heart is in Virginia)
    Posts
    2,949
    Originally posted by yaksplat
    you can use the selectall() property

    Code:
          Private Sub textbox_TB_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles textbox_TB.Click
            textbox_TB.SelectAll()
        End Sub
    is that what you needed?
    You should put the above code in the GotFocus event of the text box. An improvement would be to make one event handle all of the textboxes gotfocus events, something like:

    [Highlight=VB]
    Private Sub textbox.GotFocus (ByVal sender As Object, ByVal e As System.EventArgs) Handles textbox1.GotFocus, textbox2.GotFocus. etc
    sender.SelectAll()
    End Sub


    When adding the extra handles to the GotFocus event, my intellisense does not give me the option of "GotFocus" so I had to type it in. Anyone else experience this
    Taxes
    The more I learn about VB.NET the more I like dBaseIII Plus

    The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Nov 2003
    Location
    Chicagoland
    Posts
    92
    I kind figured it out while playing around after I posted this, but taxes' solution was great. It is actually an MDI app, so I have quite a few forms that use textboxes. One of my forms has 8 textboxes, so this worked out great.

    BTW, you're right. When you start adding events to what the subroutine handles, GotFocus wasn't one of the offered options. I did have to type it. But it worked, and that's all that matters, right?

    Well, maybe....

  5. #5
    Member
    Join Date
    Apr 2004
    Posts
    44
    wow, i didn't know you could add multiple items like that after handles. I have about 20 textboxes on my form that each have 5 events each associated with them.

    This just eliminated about 1000 lines of code


    Thanks

Posting Permissions

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



Click Here to Expand Forum to Full Width