guru kool

guru kool

  • NA
  • 16
  • 0

Windows Forms

Feb 9 2009 6:09 AM

 Hii,

 I have created a form.I open the form on the click event of a button.I want to open the form in the centre of the form on which the button is placed.Ne suggestions how to do it.

Following is wat i have implemented.

public partial class FormSelectParameters : Form

{

........etc

}

 In other application i have a button on whose click event i reate a new instance of above form.Her is the code.

private void btnSelectParameters_Click(object sender, EventArgs e)

{

   Form frmselParam = new FormSelectParameters();

if (frmselParam.ShowDialog(this) == DialogResult.OK)

{

     

     frmselParam.Visible = false;

//Tried the below line.Gives an exception saying Top level controls cannot be added.

    frmselParam.Parent=this;

}

I want to open the form at the centre of the form which is having

btnSelectParameters.

 

 


Answers (2)