Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / May 2006

Tip: Looking for answers? Try searching our database.

Panels, UserControls, and component position in the UserControl

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
dchman - 26 May 2006 01:26 GMT
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
Signature

dchman

Curtis - 26 May 2006 05:52 GMT
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
Curtis - 26 May 2006 05:53 GMT
eek... what an idiot. I am thinking of asp.net. Never mind that last
post. Could you post the panel code anyway?
dchman - 26 May 2006 12:48 GMT
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
Signature

dchman

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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.