Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / January 2005

Tip: Looking for answers? Try searching our database.

MessageBox and Focus

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
WhiskyRomeo - 03 Jan 2005 15:57 GMT
I have a message box that pops up when there is a problem after a user
clicks on a button.

After the user clicks OK on the message box, I need the focus to return to a
different control (a textbox).  Intuitively, you would think the line
MyTextbox.Focus after the MessageBox.Show line would do the the trick.  
Howerver, focus always returns to the control that initiated the show method.
Any focus method after that is ignored.

Can anyone tell me how to overide this behaviour?
Signature

wr

Carlos J. Quintero [.NET MVP] - 03 Jan 2005 16:16 GMT
I am unable to reproduce it. Try this using C# 2003: a form with a treeview
and a button, and this code:

 private void button1_Click(object sender, System.EventArgs e)
 {
  MessageBox.Show("Hi");
  treeView1.Focus();
 }

It works as expected, the focus goes to the treeview.

Signature

Carlos J. Quintero

MZ-Tools 4.0: Productivity add-ins for Visual Studio .NET
You can code, design and document much faster.
http://www.mztools.com

> I have a message box that pops up when there is a problem after a user
> clicks on a button.
[quoted text clipped - 8 lines]
>
> Can anyone tell me how to overide this behaviour?
Herfried K. Wagner [MVP] - 03 Jan 2005 17:36 GMT
"WhiskyRomeo" <WhiskyRomeo@discussions.microsoft.com> schrieb:
> I have a message box that pops up when there is a problem after a user
> clicks on a button.
[quoted text clipped - 6 lines]
> method.
> Any focus method after that is ignored.

I am not able to repro that in VB.NET 2002 using 'MsgBox' or
'MessageBox.Show'.

Signature

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

WhiskyRomeo - 04 Jan 2005 23:39 GMT
Thanks for the replies.  At least this allows me to look elsewhere for the
problem.

Bill

> I have a message box that pops up when there is a problem after a user
> clicks on a button.
[quoted text clipped - 6 lines]
>
> Can anyone tell me how to overide this behaviour?

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.