?
Solved

arrow keys acting like tab key on controls added at runtime

Posted on 2003-03-20
2
Medium Priority
?
134 Views
Last Modified: 2010-04-07
Hi, Here's my code... I add a usercontrol to a form at runtime and add textboxes to a frame on the usercontrol. When the form loads however, the arrow keys on these textboxes act like tabs, moving the cursor to the next textbox. When user clicks on another control (added at design time) on the screen and come back to the textboxes, the arrow keys start behaving fine.
Any idea why this may occur, and how I could fix it?

Thanks
manny


Private WithEvents MyEditor As VBControlExtender

Set MyEditor = MyForm.Controls.Add("ctlMyUserControl", "MyEditor")
MyEditor.Visible = True

MyEditor.object.Controls.Add "VB.TextBox", "txtName", MyEditor.object.Controls("frameUserInfo")
...
MyEditor.object.Controls.Add "VB.TextBox", "txtAddress", MyEditor.object.Controls("frameUserInfo")
0
Comment
Question by:powerstreak
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 11

Accepted Solution

by:
supunr earned 300 total points
ID: 8177658
I am not sure this will work, but try doing this in Form_Activate event....

cmdButton.SetFocus ' forcus to any design time conrol
SendKeys "{TAB}"
txtName.SetFocus ' now focus back to whereever you want

Good Luck!
0
 

Author Comment

by:powerstreak
ID: 8178062
The form starts out empty...the usercontrol is loaded at runtime.
I sent a WM_LBUTTONDOWN message to an existing control on the usercontrol during Initproperties and it worked. Wish I'd known the underlying reason for this behaviour.
Thanks though, for sending me in the right direction.

manny
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month9 days, 3 hours left to enroll

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question