keep button position constant from base class

Similar to the question I asked here when I use a form I made as a base class, and re-size it, my buttons go missing. I'm sure it is because I re-sized the form and the button placement is in a location off the page so when I re-size they are still off the page, just don't know how to fix it. A simple fix is to do the re-size on load event, but that doesn't let me design the page properly - plus I really just want the buttons to always be 10-20 up from the bottom and 5-15 from the right - no matter how I re-size the form. thanks in advance.

Base Form:

    namespace EXT
        {
        partial class ExtFormCard
            {
            private void InitializeComponent ()
                {
                this.btnSaveandClose = new System.Windows.Forms.Button();
                this.btnCancel = new System.Windows.Forms.Button();
                this.btnSave = new System.Windows.Forms.Button();
                this.SuspendLayout();
               // 
                // btnSaveandClose
                // 
                this.btnSaveandClose.Anchor = ((System.Windows.Forms.AnchorStyles)        ((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
               this.btnSaveandClose.Location = new System.Drawing.Point(899, 663);
                this.btnSaveandClose.Name = "btnSaveandClose";
                this.btnSaveandClose.Size = new System.Drawing.Size(100, 30);
                this.btnSaveandClose.TabIndex = 0;
                this.btnSaveandClose.Text = "Save and Close";
                this.btnSaveandClose.UseVisualStyleBackColor = true;
                this.btnSaveandClose.Click += new System.EventHandler(this.Click_SaveandClose);

            ... other buttons
            ...
                //
                // ExtFormCard
                // 
                this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
                this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
                this.ClientSize = new System.Drawing.Size(1200, 874);
                this.Controls.Add(this.btnSave);
                this.Controls.Add(this.btnCancel);
                this.Controls.Add(this.btnSaveandClose);
                this.Name = "ExtFormCard";
                this.Text = "ExtFormCard";
                this.ResumeLayout(false);
                }

            private System.Windows.Forms.Button btnSaveandClose;
            private System.Windows.Forms.Button btnCancel;
            private System.Windows.Forms.Button btnSave;
            }
        }

New Form:

    namespace IDVisitorWindowsForms.Manager
        {
        public partial class AnswerForm : EXT.ExtFormCard
            {
            public AnswerForm ()
                {
                InitializeComponent ();
                }
            }
        }

    namespace IDVisitorWindowsForms.Manager
        {
        partial class AnswerForm
            {
            #region Windows Form Designer generated code

            /// <summary>
            /// Required method for Designer support - do not modify
            /// the contents of this method with the code editor.
            /// </summary>
            private void InitializeComponent ()
                {
                this.SuspendLayout();
                // 
                // AnswerForm
                // 
                this.AutoScaleDimensions = new System.Drawing.SizeF (6F, 13F);
                this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
                this.ClientSize = new System.Drawing.Size (724, 411);
                this.Name = "AnswerForm";
                this.Text = "Answer Form";
                this.Load += new System.EventHandler(this.AnswerForm_Load);
                this.ResumeLayout(false);

               }

            #endregion
            }
        }

Answers


When using WinForms you can Anchor controls. This is done in the Properties box. When Anchroing you select the sides of the parent container you wish to anchor to.

Anchoring a control means it will keep its position (spacing) relative to the side(s) of the container that it is in. In your example, you'd want to bottom and right anchor your buttons so that they will always be the distance you want away from those sides.


Need Your Help

Install python, pygtk in user's space

python linux pygtk ubuntu-11.04

I am trying to install python with pygtk in my ubuntu system.

filter duplicate URLs domain from List c#

c# .net vb.net winforms filter

I have a list of 100,000 urls in list(Of string) which can contain urls in the form.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.