继续面板大小调整按键的位置 [英] keep button position on panel resize

查看:142
本文介绍了继续面板大小调整按键的位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在插科打诨的东西,应该是简单的。

我感动的工作,并试图得到一些我以前用的基本工具,但当然我没有旧的源代​​码来看看。

我们已经扩展面板有一定的标准的性质和功能(保存,关闭,保存并关闭)。

但我不能让按钮能够正确在一个调整大小位置。我把这个ExtPanel窗体上但按键保持消失为我调整,还是不动如预期(冻结在右下图)。

 公共部分类ExtPanel:用户控件
   {
   私人System.Windows.Forms.Button btnSaveandClose;
   私人System.Windows.Forms.Button btnCancel;
   私人System.Windows.Forms.Button btnSave;

   公共ExtPanel()
      {
      的InitializeComponent();
      }

//其它东西,这个类不...


}

公共部分类ExtPanel
    {
    私人无效的Ini​​tializeComponent()
       {
        this.btnSaveandClose =新System.Windows.Forms.Button();
        this.btnCancel =新System.Windows.Forms.Button();
        this.btnSave =新System.Windows.Forms.Button();
        this.panel1 =新System.Windows.Forms.Panel();
        this.panel1.SuspendLayout();
        this.SuspendLayout();
        //
        // btnSaveandClose
        //
        this.btnSaveandClose.Location =新System.Drawing.Point(899,689);
        this.btnSaveandClose.Name =btnSaveandClose;
        this.btnSaveandClose.Size =新System.Drawing.Size(100,30);
        this.btnSaveandClose.TabIndex = 0;
        this.btnSaveandClose.Text =保存并关闭;
        this.btnSaveandClose.UseVisualStyleBackColor = TRUE;
        this.btnSaveandClose.Click + =新System.EventHandler(this.Click_SaveandClose);
        this.btnSaveandClose.Anchor =((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));

        //
        // btnCancel
        //
        this.btnCancel.Location =新System.Drawing.Point(687,689);
        this.btnCancel.Name =btnCancel;
        this.btnCancel.Size =新System.Drawing.Size(100,30);
        this.btnCancel.TabIndex = 1;
        this.btnCancel.Text =取消;
        this.btnCancel.UseVisualStyleBackColor = TRUE;
        this.btnCancel.Click + =新System.EventHandler(this.Click_Close);
        this.btnCancel.Anchor =((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));

        //
        // btnSave
        //
        this.btnSave.Location =新System.Drawing.Point(793,689);
        this.btnSave.Name =btnSave;
        this.btnSave.Size =新System.Drawing.Size(100,30);
        this.btnSave.TabIndex = 2;
        this.btnSave.Text =保存;
        this.btnSave.UseVisualStyleBackColor = TRUE;
        this.btnSave.Click + =新System.EventHandler(this.Click_Save);
        this.btnSave.Anchor =((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));

        //
        // PANEL1
        //
        this.panel1.AutoScroll = TRUE;
        this.panel1.Controls.Add(this.btnSave);
        this.panel1.Controls.Add(this.btnCancel);
        this.panel1.Controls.Add(this.btnSaveandClose);
        this.panel1.Location =新System.Drawing.Point(0,0);
        this.panel1.Name =PANEL1;
        this.panel1.Size =新System.Drawing.Size(1008,730);
        this.panel1.TabIndex = 0;
        //
        // ExtPanel
        //
        this.Controls.Add(this.panel1);
        this.Name =ExtPanel;
        this.Size = this.panel1.Size;
        this.Click + =新System.EventHandler(this.click_this);
        this.panel1.ResumeLayout(假);
        this.ResumeLayout(假);

        }

    #endregion

    私人System.Windows.Forms.Panel PANEL1;


}
 

解决方案

<打击>您是否尝试过固定的按钮?

...我错过了锚code。

如果你有,你想留在较低的右上角调整的形式时,右下角的角落的一个按钮,设置它的锚固性能底部,右侧。

更新:
我装你的code。你有一个小组内 ExtPanel 。如果您码头(填写)的面板,那么你应该工作正常,通过调整ExtPanel。

I've been messing around with something that should be simple.

I've moved jobs and trying to get some of the basic tools I have used before, but of course I don't have the old source to look at.

We had extended panel to have some standard properties and functions (save, close, save and close).

But I can't get the buttons to be positioned correctly on a resize. I put this ExtPanel on a form but the buttons keep disappearing as I resize, or don't move as expected (frozen on bottom right).

The class

public partial class ExtPanel: UserControl
   {
   private System.Windows.Forms.Button btnSaveandClose;
   private System.Windows.Forms.Button btnCancel;
   private System.Windows.Forms.Button btnSave;

   public ExtPanel ()
      {
      InitializeComponent ();
      }

// misc things this class does...


}

public partial class ExtPanel
    {
    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.panel1 = new System.Windows.Forms.Panel();
        this.panel1.SuspendLayout();
        this.SuspendLayout();
        // 
        // btnSaveandClose
        // 
        this.btnSaveandClose.Location = new System.Drawing.Point(899, 689);
        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);
        this.btnSaveandClose.Anchor = ((System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));

        // 
        // btnCancel
        // 
        this.btnCancel.Location = new System.Drawing.Point(687, 689);
        this.btnCancel.Name = "btnCancel";
        this.btnCancel.Size = new System.Drawing.Size(100, 30);
        this.btnCancel.TabIndex = 1;
        this.btnCancel.Text = "Cancel";
        this.btnCancel.UseVisualStyleBackColor = true;
        this.btnCancel.Click += new System.EventHandler(this.Click_Close);
        this.btnCancel.Anchor = ((System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));

        // 
        // btnSave
        // 
        this.btnSave.Location = new System.Drawing.Point(793, 689);
        this.btnSave.Name = "btnSave";
        this.btnSave.Size = new System.Drawing.Size(100, 30);
        this.btnSave.TabIndex = 2;
        this.btnSave.Text = "Save";
        this.btnSave.UseVisualStyleBackColor = true;
        this.btnSave.Click += new System.EventHandler(this.Click_Save);
        this.btnSave.Anchor = ((System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));

        // 
        // panel1
        // 
        this.panel1.AutoScroll = true;
        this.panel1.Controls.Add(this.btnSave);
        this.panel1.Controls.Add(this.btnCancel);
        this.panel1.Controls.Add(this.btnSaveandClose);
        this.panel1.Location = new System.Drawing.Point(0, 0);
        this.panel1.Name = "panel1";
        this.panel1.Size = new System.Drawing.Size(1008, 730);
        this.panel1.TabIndex = 0;
        // 
        // ExtPanel
        // 
        this.Controls.Add(this.panel1);
        this.Name = "ExtPanel";
        this.Size = this.panel1.Size;
        this.Click += new System.EventHandler(this.click_this);
        this.panel1.ResumeLayout(false);
        this.ResumeLayout(false);

        }

    #endregion

    private System.Windows.Forms.Panel panel1;


}

解决方案

Have you tried anchoring the button?

...I missed the anchoring code.

If you have a button in the lower right-hand corner that you want to stay in the lower right-hand corner when resizing the form, set it's anchor properties to Bottom, Right.

Update:
I loaded your code. You have a panel inside of ExtPanel. If you dock (Fill) that panel then you should be working fine by resizing ExtPanel.

这篇关于继续面板大小调整按键的位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆