Click here to Skip to main content
15,899,754 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

Please help me ,

i have two form
1) Main Form
2) Child Form (Showing progress GIF image for some time)

To call child form i have used thread :

Thread ProgressT = null;
public Progress frm = null;

C#
ProgressT = new Thread(ProgressViewTest);
ProgressT.IsBackground = true;
ProgressT.Start();


// Call ProgressViewTest

C#
void ProgressViewTest()
      {
          try
          {
              if (frm == null)
                  frm = new Progress();

              if (frm.Visible == true)
                  frm.Close();

               frm.ShowDialog();
          }
          catch (Exception ex)
          {
              if (frm != null)
              {
                  if (frm.Visible == true)
                      frm.Close();
              }
          }
      }



How to open child form in center of parent.

Thanks in Advance.

[updated on behalf of the OP]
Thanks,

i am not hiding a part of one form behind another form
on second form i have used one GIF image to show user to wait for some time, because some process going on at backend. so form 2 (GIF image) call by tread from first form. aand i want to make that form in center of parent.
[/updated]
Posted
Updated 3-Sep-14 20:07pm
v2

First, your form are not child and parent to each other (unless they are MDI parent and MDI child). Child-parent relationship is made defunct for forms.

There is no special solution for this "problem". You simply need to use the property Location and Size for both form and set location of one form the way it is placed in the middle of another one. (But why would you hide a part of one form behind another one? are you sure this would be acceptable UI design?)

—SA
 
Share this answer
 
Thanks,

i am not hiding a part of one form behind another form
on second form i have used one GIF image to show user to wait for some time, because some process going on at backend. so form 2 (GIF image) call by tread from first form. aand i want to make that form in center of parent.
 
Share this answer
 
Comments
vangapally Naveen Kumar 4-Sep-14 2:10am    
if you want comment or ask something don't put it in answer put it in comments ..
Quote:
i am not hiding a part of one form behind another form
on second form i have used one GIF image to show user to wait for some time, because some process going on at backend. so form 2 (GIF image) call by tread from first form. aand i want to make that form in center of parent.

Technically the second form should be a progress dialog[^].
 
Share this answer
 
For show form center to its Parent window


set the start postion for child window.
like
C#
private void OpenForm(Form parent)
{
    FormLoading frm = new FormLoading();
    frm.Parent = parent;
    frm.StartPosition = FormStartPosition.CenterParent;
    frm.ShowDialog();
}



for more info form start position
http://msdn.microsoft.com/en-us/library/system.windows.forms.form.startposition.aspx[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900