Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hi All I've just taken the step

Status
Not open for further replies.

cmahon

Programmer
Sep 25, 2003
27
IE
Hi All

I've just taken the step up from VB6 to VB.NET and I'm having lots of trouble with it (although I expected this). Apologies if this sounds like a ridiculously easy question but to set focus to a control do I just need to code

controlname.focus()

I've been trying this but to no avail.

Any tips would be appreciated

Thanks

cmahon
 
Hi, just set the tab order to 1, and this will set focus when the page loads up. To view the tab order click VIEW | Tab Order. This is quite a nice feature to show the tab order on your page.
Let me know if you don't come right
Mark
 
Not sure if it is a glitch or what, but controlname.Focus() does not work right. You can try this (it works for me)

controlname.Select()

if it is a text box then it takes 2 steps to get it right

textBox1.Select()
textBox1.Select(0,0)


the first select, selects the text in the textbox, the second one unselects it and leaves the focus in the textbox.

Becca

Somtimes, the easy answer is the hardest to find. :)
 
The reason that focus is not working is because the form is still loading. Add show before your call like so


Sub Form1_Load (...)

Me.Show()
TextBox1.Focus()

End Sub

DotNetDoc
M.C.S.D.
---------------------------------------

Tell me and I forget. Show me and I remember. Involve me and I understand.
- Anonymous Chinese Proverb
-----------------------------------
If you can't explain it simply, you don't understand it well enough.
- A. Einstein
 
Hi,

I've managed to get the focus to work so thanks for the help there. I've run into another problem however, when I run the program, login to the database and retrieve the values I want , the program then sets focus to a text box awaiting input.

At this point the program ends and returns to the immediate(output) window and reports an error that there are "No Symbols loaded" for some of the references that I have in the project. Has anyone come across this problem before?

I'm quite confused about what exactly the error is telling me. Is it the fact that I have them included in the project but that I don't IMPORT them anywhere?

Thanks

cmahon
 
I have not seen this before. I also find it best to start a new thread when changing the subject ... just so you know.

Becca

Somtimes, the easy answer is the hardest to find. :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top