473,397 Members | 2,033 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,397 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 2407
"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
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
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.