Panels, UserControls, and component position in the UserControl

G

Guest

I inherited a C# Windows app (.net 2.0) . There is a main form with a panel
and menu. When the user selects a menu item, a usercontrol form is added to
the panel and displayed. The User control forms have things like
datagridview and command buttons, as well as a panel that gets loaded with
another user control. When modifying one of the user controls I can position
the components to where I want. However, when I run the app and a user
control is loaded to the panel, the components on the user control get
re-positioned. For example, on one user control there are two buttons
(side-by-side) and a datagridview (below the two buttons). When the app
runs, the position of the datagridview has moved to cover-up the two buttons.

I am new to the use of panels and user controls, and am not sure where to
look to figure out what is happening and how to resolve it. Can anyone point
me in the right direction?

thanks

Dan
 
C

Curtis

Is this a flow or grid positioned page? It sounds like you are
expecting grid positioning (which is a bit of a pain to work with). Why
don't you post the panel HTML code?

Curtis
 
C

Curtis

eek... what an idiot. I am thinking of asp.net. Never mind that last
post. Could you post the panel code anyway?
 
G

Guest

I am not sure what code to post - here is a start:

From the intialize section of the main form
//
// pnlControls
//
this.pnlControls.Anchor =
((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top
| System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.pnlControls.Location = new System.Drawing.Point(0, 0);
this.pnlControls.Name = "pnlControls";
this.pnlControls.Size = new System.Drawing.Size(w, h);
this.pnlControls.TabIndex = 0;
this.pnlControls.Paint += new
System.Windows.Forms.PaintEventHandler(this.pnlControls_Paint);

menu item that loads the panel with the user control "ucTaxAdjustment"
private void menuItemTaxAdjustment_Click(object sender, System.EventArgs e)
{
if (!pnlControls.ControlExists(controlName_TaxAdjustment))
{
this.pnlControls.AddControl(new
ucTaxAdjustment(),controlName_TaxAdjustment);
}
this.pnlControls.ActiveControl = controlName_TaxAdjustment;
}

Load event of the user control
private void ucTaxAdjustment_Load(object sender, System.EventArgs e)
{
Dock = DockStyle.Fill;
if (this.pnlCompany.Controls.Count == 0)
this.pnlCompany.Controls.Add(ucCS); //loads another user control on a panel
on this user control
}

thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top