473,407 Members | 2,629 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,407 software developers and data experts.

How to set Focus on a control AFTER a ShowDialog call?

Ed
I have 2 forms:

Form1 calls Form2 via a Form2.ShowDialog(me) call. However, after
Form2 appears, I want to set the focus to a specific control, but I
can't. Does anyone know how to do this?

Thanks,
ed
Jul 19 '05 #1
2 2409
"Ed" <le****@hotmail.com> schrieb

Is it necessary to post to all these groups?
I have 2 forms:

Form1 calls Form2 via a Form2.ShowDialog(me) call. However, after
Form2 appears, I want to set the focus to a specific control, but
I can't.
Why?
Does anyone know how to do this?


Either set the tab order at design time, or use the following code:

Protected Overrides Sub OnActivated( _
ByVal e As System.EventArgs)

Static done As Boolean

MyBase.OnActivated(e)

If Not done Then
done = True
TheControl.Focus()
End If

End Sub
--
Armin

Jul 19 '05 #2
Hello,

"Ed" <le****@hotmail.com> schrieb:
Form1 calls Form2 via a Form2.ShowDialog(me) call. However, after
Form2 appears, I want to set the focus to a specific control, but I
can't. Does anyone know how to do this?


1. I hate X-Posts.
2. The focus will be set to the control with the smallest TabIndex value.
Maybe you want to set the controls' TabIndex properties.

HTH,
Herfried K. Wagner
--
MVP · VB Classic, VB .NET
http://www.mvps.org/dotnet
Jul 19 '05 #3

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

Similar topics

2
by: Mark Ingram | last post by:
Hi, ive just had to make a Find dialog for an application and to get it in a similar style to the MS ones i have had to set the control style to TopMost so that i can move the caret around...
13
by: Mike L | last post by:
I have a child form frmDataEntry call up another child form frmDealerSearch. If the user clicks on cancel on frmDealerSearch, I want to close frmDealerSearch and put the focus on txtDealerNum on...
2
by: Ed | last post by:
I have 2 forms: Form1 calls Form2 via a Form2.ShowDialog(me) call. However, after Form2 appears, I want to set the focus to a specific control, but I can't. Does anyone know how to do this? ...
4
by: Phil | last post by:
Hi Does anybody know of a way of preventing a form from receiving the focus? Okay, I know I can do it via a ShowDialog call in another form but what if I don't want to use that technique. My...
3
by: Chris | last post by:
I have a form that calls ShowDialog on a number of different forms at different times. I want to be able to know anytime the form loses focus. But Form.Focused isn't ever true once a control has...
0
by: pedery | last post by:
I have created an image selection dropdown editor for use in a PropertyGrid. My selector form is called dropdown by a IWindowsFormsEditorService and so far it's all sweet. On my selector form I...
7
by: Dave Booker | last post by:
I am using a WebBrowser object in my .NET 2.0 application, but it is not shown to the user. Every time a timer event triggers it to perform a m_WebBrowser.Navigate() I get that classic IE 'click'...
6
by: =?Utf-8?B?ZHNoZW1lc2g=?= | last post by:
Hello, I have a windows form with a TreeView control. When I first open the tree all nodes are colapsed. Then, I expand some of them and close the form. When I call Form.showDialog() once again...
2
by: Jonathan N. Little | last post by:
As part of a JavaScript precheck form validation I noticed a problem with trying to return focus to the field with an error. I have setup a demo page. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.