I'm using dock panel and shaped form and its a MDI application.My requirement is I should always have only one instance of the form .Create if it is not available or activate it.I used Singleton pattern to acheive this.
I have problems activating it or showing it next time.I couldn't find any sample .
Please advice with the exact sample
thanks in advance
5 Answers, 1 is accepted
Thank you for writing us.
I have attached a sample program that reproduces the desired behavior. When you click the button Show/Hide, you get the only instance of the mdi child form. Then you show or hide this form depending on its current state.
If you need additional assistance, do not hesitate to contact us.
Regards,
Nikolay
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
Thanks this works.But surpringly I found that my project doesn't use MDIParent - MDI Child concept rather uses Docking Manager and Panel similar to your samples
When I try to implement the same ?It works for the first time,when click second time,it shows blank form.
Not sure whether I should call .refresh or initializecomponent.Please assist
if (frmJobSummary is nothing )
frmJobSummary=FrmJobSummary.GetInstance();
if not frmJobSummary is nothing and not frmJobSummary.isDisposed then
if (frmJobSummary.isvisible=true)
frmJobSummary.activate()
frmJobSummary.refresh()
else
frmJobSummary.show()
frmJobSummary.refresh()
end if
else
frmJobSummary =FrmJobSummary.GetInstance()
frmJobSummary.Show()
I doubt some thing is missing here?
Some how I'm able to get some sample from http://www.telerik.com/community/forums/thread/b311D-bbgeae.aspx
dockingManager1.SetDocument((DocumentPane)form.Parent) is throwing error saying cannot typecast from mdiclient to documentpane.Please assist.
cRewardsForms objcRewardsForms = new cRewardsForms();//Collectuion Class
BaseForm objBaseForm;
#region
"Manage Form Display"
private void Display(string formName, string relatedForm)
{
if (objcRewardsForms[formName] != null)
{
objBaseForm = objcRewardsForms[formName];
if (objBaseForm == null || objBaseForm.IsDisposed)
{
objBaseForm = GetInstance(formName);
if (objBaseForm != null)
objcRewardsForms[formName] = objBaseForm;
}
}
else
{
objBaseForm = GetInstance(formName);
if (objBaseForm != null)
objcRewardsForms.Add(formName, objBaseForm);
}
if (objBaseForm != null)
{
objBaseForm.MdiParent =
this;
if (objBaseForm.Visible)
{
objBaseForm.Activate();
for (int i = 0; i < dockingManager.MdiChildren.Length; i++)
{
Form f;
f = dockingManager.MdiChildren[i];
if (f.Name == formName)
{
dockingManager.SetDocument((
DocumentPane)objBaseForm.Parent);
}
}
}
else
{
DocumentPane documentPane = new DocumentPane();
documentPane.Text = objBaseForm.Name;
objBaseForm.Parent = documentPane;
objBaseForm.Show();
}
}
else
MessageBox.Show("Error");
HideOtherForms(formName, relatedForm);
}
private BaseForm GetInstance(string formName)
{
if (formName == "SingleForm")
return SingleForm.Instance;
else if (formName == "SingleForm2")
return SingleForm2.Instance;
else if (formName == "Details")
return Details.Instance;
else
return null;
}
Please find the answer to your question in the support ticket you have opened.
Best wishes,
Nikolay
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center