Friday, April 15, 2011

focusing forms

Hi,

If i click button event in form1 form2 should be focus, if i click button event in form2 form1 should focus in c#

How can I do this ?

From stackoverflow
  • Store a reference to the other form (ie Form1 has a reference to Form2) and in the button click event handlers, use:

    otherFormInstance.Focus();
    
  • Microsoft recommends not calling Focus on a form, instead use the form's Activate method. Here is an excerpt from MSDN:

    Focus is a low-level method intended primarily for custom control authors. Instead, application programmers should use the Select method or the ActiveControl property for child controls, or the Activate method for forms.

0 comments:

Post a Comment