|
-
Jun 3rd, 2004, 09:42 AM
#1
Thread Starter
Lively Member
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.
-
Jun 3rd, 2004, 09:47 AM
#2
Member
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?
-
Jun 3rd, 2004, 10:35 AM
#3
PowerPoster
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.
-
Jun 3rd, 2004, 11:03 AM
#4
Thread Starter
Lively Member
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....
-
Jun 3rd, 2004, 11:21 AM
#5
Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|