|
-
Oct 31st, 2002, 12:55 AM
#1
Thread Starter
Lively Member
firsttime focus
how can I give focus to a textbox when the application starts?
where should i put the code 'textbox1.focus()?
thanks in advance
when in doubt, win the trick
-
Oct 31st, 2002, 01:43 AM
#2
couldnt you just set the tabindex of it to 0?
you could also put textbox.focus () in form_load, couldnt you?
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB )
VB.NET to C# conversion tips!!
-
Oct 31st, 2002, 02:40 AM
#3
Thread Starter
Lively Member
hi Mr.Polite
I placed some textboxes in a tabControl and made the tabindex of a textbox to 0.
but it didn't work. why?
it's working otherwise
when in doubt, win the trick
-
Oct 31st, 2002, 05:24 AM
#4
Actually instead of SetFocus its now called Select() but setting the TabIndex to 0 should work.
-
Oct 31st, 2002, 08:56 AM
#5
Thread Starter
Lively Member
but setting tabindex to 0 for a textbox which is placed in a tabcontrol is not getting focus. do u know why?
by the way
Instead of setfocus it's object.focus() in vb.net right?
i think select method is used to make a selection of the contents of a textbox. right?
when in doubt, win the trick
-
Oct 31st, 2002, 08:58 AM
#6
Thread Starter
Lively Member
but setting tabindex to 0 for a textbox which is placed in a tabcontrol is not getting focus. do u know why?
by the way
Instead of setfocus it's object.focus() in vb.net right?
i think select method is used to select a range of text in textbox. right?
when in doubt, win the trick
-
Oct 31st, 2002, 03:27 PM
#7
errrrrrrrrm, here's a really dumb way to do it. Since no one else can think of the correct way :
VB Code:
Private Sub TabControl1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TabControl1.SelectedIndexChanged
Dim firstCtrl, ctrl As Control
For Each ctrl In TabControl1.SelectedTab.Controls
If firstCtrl Is Nothing OrElse (ctrl.TabIndex < firstCtrl.TabIndex) Then
firstCtrl = ctrl
End If
Next
If Not firstCtrl Is Nothing Then firstCtrl.Focus()
End Sub
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB )
VB.NET to C# conversion tips!!
-
Nov 1st, 2002, 12:01 AM
#8
Thread Starter
Lively Member
ha ha! thank you very much Mr.Polite. But ....
should we really write that much code for that?
any way thanks
when in doubt, win the trick
-
Nov 1st, 2002, 01:23 AM
#9
Frenzied Member
I dont think you need all that code. Just put
in the form load event.
Dont gain the world and lose your soul
-
Nov 1st, 2002, 01:39 AM
#10
Originally posted by DevGrp
I dont think you need all that code. Just put
in the form load event.
well, he wants the control to have the focus as the tabs are selected. I wrote the code like that so it would select the control with the lowest tabindex, everytime you select a different tab. This works even if you dont know the name of the control with the lowest tabindex in each tab
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB )
VB.NET to C# conversion tips!!
-
May 18th, 2004, 01:11 PM
#11
New Member
Setting focus on Textbox at program start
This is how to set focus
Private Sub Form_activate()
text1.setfocus
End Sub
text1 refering to which textbox you wish to focus on.
Do this in order of forms that appear and on those forms which
boxes you wish to start the sequence of tabs with.
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
|