We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

FloatingForm and FormClose event

Hello,

Creating floating form containing our form using recommended method:


formToFloat.TopLevel = false;
formToFloat.ShowInTaskbar = false;
formToFloat.FormBorderStyle = FormBorderStyle.None;
dockingManager1.FloatControl(formToFloat, formToFloat.Bounds);
FloatingForm f = (((DockHost)formToFloat.Parent).ParentForm as FloatingForm));
f.FormClosed += delegate {
MessageBox.Show("FormClosed");
};


If I close floating form (pressing by "x" button of tool window) no FormClosed event is fired.
But it's fires when application exit.

How to handle FormClosed event?

Regards,
Serguei

4 Replies

MU Murugan Syncfusion Team February 6, 2007 06:28 PM UTC

Hi Serguei,

When a FloatingForm is closed, Form's visibility is set to false. The form can be reopened using dockingManager.SetDockVisibility( form , true ). This is the reason for not firing the FormClosed event. When application is closed, Form is disposed. So FormClosed event is fired.

How to handle FormClosed event?

Whenever the control visibility is changed, DockVibilityChanged event is fired. So we could initiate user defined event in this handler to achieve our requirement.

Here is the code snippet:

public delegate void FormClosed(Object sender , Syncfusion.Windows.Forms.Tools.DockVisibilityChangedEventArgs e );
public event FormClosed FormClosedEvent;

private void dockingManager1_DockVisibilityChanged(object sender, Syncfusion.Windows.Forms.Tools.DockVisibilityChangedEventArgs arg)
{
if (!this.dockingManager1.GetDockVisibility(arg.Control) &&
this.dockingManager1.IsFloating(arg.Control))
{
this.FormClosedEvent += new FormClosed(Form1_FormClosedEvent);
this.FormClosedEvent(sender, arg);
}
}

void Form1_FormClosedEvent(object sender, Syncfusion.Windows.Forms.Tools.DockVisibilityChangedEventArgs e)
{
Console.WriteLine(e.Control.Name);
}

Herewith I have also attached the sample. Please have a look at the sample and let me know if it helps.

TDM_55889

Thanks for choosing Syncfusion products.

Regards,
Murugan P.S


ST Serguei Tarassov February 7, 2007 09:45 AM UTC

Murugan,

Thanks for help.
Finally, I use code like this:


if (!dockingManager.GetDockVisibility(arg.Control) && arg.Control is Form)
{
((Form) arg.Control).Close();
}


Regards,
Serguei


ST Serguei Tarassov February 7, 2007 02:27 PM UTC

Murugan,

What about "Load" event ?
It doesn't fired too and i'm afraid that your method is not working in this case: "DockVisibilityChanged" event is not fired when creating new control.

Regards,
Serguei


MU Murugan Syncfusion Team February 7, 2007 05:48 PM UTC

Hi Serguei,

By customizing the DockingManager, we could initiate the FormLoad event when the Form is floated.

Herewith I have attached the sample. Please refer to the sample and let me know if it helps.

TDM_55889

Thanks,
Murugan P.S

Loader.
Live Chat Icon For mobile
Up arrow icon