473,320 Members | 1,987 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,320 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
Nov 19 '05 #1
2 11265
"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

Nov 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
Nov 19 '05 #3

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

Similar topics

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? ...
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...
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...
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...
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: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.