473,387 Members | 1,834 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Problem with setting focus

I have an application with 2 forms. Form1 is the main form and has 2 text
boxes on it. Form2 is a datagrid showing a list of workorders that are to be
manufactured.

The user can use the mouse to select the work order on form2 and data is
populated on form1 with the partid and work order. It is then supposed to
shift Focus to form1 and the text box containing the workorder BUT focus is
being kept on Form2.

What do I need to do to properly get the focus to change?

Heres the code used to change focus:

Form1.txtWorkOrder.Focus ()

Jan 6 '06 #1
3 1094
"Darrell Wesley" <Da***********@discussions.microsoft.com> schrieb:
I have an application with 2 forms. Form1 is the main form and has 2 text
boxes on it. Form2 is a datagrid showing a list of workorders that are to
be
manufactured.

The user can use the mouse to select the work order on form2 and data is
populated on form1 with the partid and work order. It is then supposed to
shift Focus to form1 and the text box containing the workorder BUT focus
is
being kept on Form2.

What do I need to do to properly get the focus to change?


Call the form's 'Activate' method prior to calling the control's 'Focus'
method.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Jan 6 '06 #2
I added form1.activate to the code but focus is still being retained on
form2. What else may be causing this behavior? (The same application in VB6
works just fine - this is in VB2003)

"Herfried K. Wagner [MVP]" wrote:
"Darrell Wesley" <Da***********@discussions.microsoft.com> schrieb:
I have an application with 2 forms. Form1 is the main form and has 2 text
boxes on it. Form2 is a datagrid showing a list of workorders that are to
be
manufactured.

The user can use the mouse to select the work order on form2 and data is
populated on form1 with the partid and work order. It is then supposed to
shift Focus to form1 and the text box containing the workorder BUT focus
is
being kept on Form2.

What do I need to do to properly get the focus to change?


Call the form's 'Activate' method prior to calling the control's 'Focus'
method.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Jan 6 '06 #3
As it turns out the "Click" event and the "CurrentCellChanged" event were
being handled by the same routine. The problem appears to be in the
CurrentCellChanged area.

When I took the "currentCellChanged" out of the picture things worked as
expected but now I have to click in the extreme left hand column where the
row indicator is, clicking inside a cell in the grid has no effect. If I add
a call to the Click event handler the same problem would show up (appeared as
if both events were being riggered).

"Herfried K. Wagner [MVP]" wrote:
"Darrell Wesley" <Da***********@discussions.microsoft.com> schrieb:
I have an application with 2 forms. Form1 is the main form and has 2 text
boxes on it. Form2 is a datagrid showing a list of workorders that are to
be
manufactured.

The user can use the mouse to select the work order on form2 and data is
populated on form1 with the partid and work order. It is then supposed to
shift Focus to form1 and the text box containing the workorder BUT focus
is
being kept on Form2.

What do I need to do to properly get the focus to change?


Call the form's 'Activate' method prior to calling the control's 'Focus'
method.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Jan 10 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: CES | last post by:
All, I'm having a problem returning focus back to an input field in Netscape. The code works in IE and Opera but not in netscape6+. Basically I have a function that is called upon...
0
by: Shravan | last post by:
Hi, I have a Windows Forms Custom DataGrid, which is put in a usercontrol, which on setting DataSource is setting focus to grid. The call stack for setting the focus is as follows. This is not...
1
by: avnrao | last post by:
Hi, I am facing a problem with control.focus (javascript). Here is the description of the issue. 1. I have 2 aspx files. on Aspx1 I have button named NewRow. Clicking on this, will redirect...
0
by: dgk | last post by:
I've tried setting the tab order using the tab order tool (VS2005) but when the form finishes loading, the focus is on the tab control and not the first textbox on the form. The textbox is inside a...
1
by: clickon | last post by:
For testing purposes i have got a 2 step WizardControl. Eqach step contains a text box, TextBox1 and TextBox2 respectively. If i put the following code in the respective activate event handlers...
1
by: clickon | last post by:
For testing purposes i have got a 2 step WizardControl. Eqach step contains a text box, TextBox1 and TextBox2 respectively. If i put the following code in the respective activate event handlers for...
4
by: tcole6 | last post by:
My problem appears to be Firefox specific. I have a hyperlink that loads a new window. This window contains hyperlinks that call javascript functions in the parent window and then closes the...
1
by: Werner Schmidt | last post by:
Dear group, I have a very strange behaviour: In a loop there are several TextBoxes initialized: TextBox objTextBox = null; // one declaration for-loop // multiple initialisations
14
by: Wayne | last post by:
I posted about this problem over 12 months ago and even after Vista SP1 the problem still exists when running an Access database (A2003 and A2007 tested) under Vista. A workaround was suggested by...
1
by: Drelus | last post by:
I'm using an Ajax call to open a search box in the page and I want the focus to go to the box automatically. So, in the httpObject.responseText, I tried sending the following in addition to the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.