Hello all,

Whenever I create a new form in a form while pushing a button. Every time I push the button and new form created. I dont want this. Example : If form2 exist and OPEN so bring it to front. I cant arrange it, I tried bringtofront or this.Close() in deactive form event...

Use the Form Show() and Hide() methods.

I tried it but no solitions :(
this.show(); in Activeted form event and this.hide(); in deactiveted form event but they are closed ( hide) my forms and I can not see them. I want to minimize the form and when i try to open same form minimize form becomes to maxisize...

Have you tried Form.Activate ?

I tried it but no solitions :(
this.show(); in Activeted form event and this.hide(); in deactiveted form event but they are closed ( hide) my forms and I can not see them. I want to minimize the form and when i try to open same form minimize form becomes to maxisize...

try hiding the active form first.
then set the active form = second one and call the show() method and focus() methodon it.

I think this is what you want?

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace daniweb
{
  public partial class frmFindForm : Form
  {
    public frmFindForm()
    {
      InitializeComponent();
    }

    private static Form FindOpenForm(Type typ)
    {
      for (int i1 = 0; i1 < Application.OpenForms.Count; i1++)
      {
        if (!Application.OpenForms[i1].IsDisposed && (Application.OpenForms[i1].GetType() == typ))
        {
          return Application.OpenForms[i1];
        }
      }
      return null;
    }

    private void button1_Click(object sender, EventArgs e)
    {
      frm1 f = (frm1)FindOpenForm(typeof(frm1));
      if (f == null)
        f = new frm1();
      if (!f.Visible)
        f.Show();
      f.BringToFront();
    }

    private void button2_Click(object sender, EventArgs e)
    {
      frm2 f = (frm2)FindOpenForm(typeof(frm2));
      if (f == null)
        f = new frm2();
      if (!f.Visible)
        f.Show();
      f.BringToFront();
    }
  }
}

You get a great, when you were here then my problems are solved, thank you very much. My prayers to you my friend ...Thread is solved... ;)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.