My friend in order to set the focus to a control you have to make it like this:
Have fun.Code:Me.ActiveControl = maskedtextbox1
|
|
hi all
i have 4 forms i have made a password form(form4) wich i started when form 1 loads
i have set on form 4 loadCode:If My.Settings.Userpassenable = Enabled Then Form4.ShowDialog() End If
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
My friend in order to set the focus to a control you have to make it like this:
Have fun.Code:Me.ActiveControl = maskedtextbox1
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.
maskedtextbox1.select will place the caret in the box and waiting for user input.
Close Counts for Horseshoes, Handgranades, and Nuclear Missiles!
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.
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
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.
2007, 2008, 2009, 2010
Why is my data not saved to my database? | Communicating between multiple forms
MSDN: Data Walkthroughs | "How Do I?" Videos
My Blog: Custom Events | Dynamic GDI+ Drawing
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.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks