Visual Basic .NET Forums  
Click here to advertise with us

Go Back   Visual Basic .NET Forums > VB.NET > VB.NET General Discussion

VB.NET General Discussion VB.NET general discussion area

VB.NET Forums Newsletter Signup:
Email address:


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-27-2009, 9:29 AM
VB.NET Forum Enthusiast
.NET Framework: .NET 3.5 (VS 2008)
 
Join Date: Mar 2009
Age: 26
Posts: 34
Reputation: 23
didgydont will become famous soon enough
Default combobox steals focus

hi all
i have 4 forms i have made a password form(form4) wich i started when form 1 loads
Code:
If My.Settings.Userpassenable = Enabled Then
            Form4.ShowDialog()
        End If
i have set on form 4 load
maskedtextbox1.focse()
but the combo box on form 1 keep taking focus
i found that out by setting Form4.ShowDialog() to Form4.Show() on form 1 any ideas ?
thank you
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 06-27-2009, 11:15 AM
VB.NET Forum Enthusiast
.NET Framework: .NET 3.5 (VS 2008)
 
Join Date: Nov 2005
Age: 34
Posts: 54
Reputation: 55
pitaridis is on a distinguished programming path ahead
Default

My friend in order to set the focus to a control you have to make it like this:

Code:
Me.ActiveControl = maskedtextbox1
Have fun.
__________________
If you can help someone, just do it. Do not try to prove that you are more cleaver than other people.

Excuse me for my English but I am from Greece and my English is not perfect.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 06-27-2009, 11:19 AM
newguy's Avatar
VB.NET Forum Miyagee
.NET Framework: .NET 3.5 (VS 2008)
 
Join Date: Jun 2008
Location: Denver Co, USA
Posts: 499
Reputation: 41
newguy will become famous soon enough
Default

maskedtextbox1.select will place the caret in the box and waiting for user input.
__________________
Close Counts for Horseshoes, Handgranades, and Nuclear Missiles!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 06-27-2009, 11:49 AM
VB.NET Forum Enthusiast
.NET Framework: .NET 3.5 (VS 2008)
 
Join Date: Nov 2005
Age: 34
Posts: 54
Reputation: 55
pitaridis is on a distinguished programming path ahead
Default

The select method is for selecting the contents of the control. Of course the select method will activate the control but this is not the right way to activate it.
__________________
If you can help someone, just do it. Do not try to prove that you are more cleaver than other people.

Excuse me for my English but I am from Greece and my English is not perfect.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 06-27-2009, 8:46 PM
VB.NET Forum Enthusiast
.NET Framework: .NET 3.5 (VS 2008)
 
Join Date: Mar 2009
Age: 26
Posts: 34
Reputation: 23
didgydont will become famous soon enough
Default

thank you both very much
i went with "Me.ActiveControl = maskedtextbox1"
but "maskedtextbox1.select" will be a good thing to remember
thank you both again
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 06-27-2009, 11:57 PM
jmcilhinney's Avatar
VB.NET Forum Moderator
.NET Framework: .NET 3.5 (VS 2008)
 
Join Date: Aug 2004
Location: Sydney, Australia
Age: 40
Posts: 6,006
Reputation: 538
jmcilhinney VB.NET gold medalistjmcilhinney VB.NET gold medalistjmcilhinney VB.NET gold medalistjmcilhinney VB.NET gold medalistjmcilhinney VB.NET gold medalistjmcilhinney VB.NET gold medalistjmcilhinney VB.NET gold medalistjmcilhinney VB.NET gold medalistjmcilhinney VB.NET gold medalistjmcilhinney VB.NET gold medalistjmcilhinney VB.NET gold medalist
Default

Quote:
Originally Posted by pitaridis View Post
The select method is for selecting the contents of the control. Of course the select method will activate the control but this is not the right way to activate it.
That is not correct. Select with no parameters is inherited from the control class and simply sets focus to the control. It's functionally equivalent to setting the ActiveControl property. Select with two Integer parameters is for selecting text within the control and it will NOT affect focus at all.

MaskedTextBox.Select Method (System.Windows.Forms)

As for the original question, there's probably no need to explicitly set focus to any particular control. When a form is displayed for the first time it will focus the first control in the tab order. If you want your MaskedTextBox to initially have focus then you should simply make it first in the tab order. This may not be possible in a complex layout but for simple forms it's the best way to go.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 06-28-2009, 3:43 AM
VB.NET Forum Enthusiast
.NET Framework: .NET 3.5 (VS 2008)
 
Join Date: Nov 2005
Age: 34
Posts: 54
Reputation: 55
pitaridis is on a distinguished programming path ahead
Default

The tab order is an other good idea that you suggested. Anyway, I think that we helped didgydont to solve his problem.

Have a nice day both of you.
__________________
If you can help someone, just do it. Do not try to prove that you are more cleaver than other people.

Excuse me for my English but I am from Greece and my English is not perfect.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





All times are GMT -4. The time now is 8:23 AM.

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2


For advertising opportunities click here.