gpt4 book ai didi

c# - 按钮 anchor 的重新定位不如组中的其他控件快

转载 作者:行者123 更新时间:2023-11-30 15:21:09 25 4
gpt4 key购买 nike

我试图将两个按钮保持在组框中的相同位置,而其他控件可以调整大小。

这是正常情况下的样子,没有调整大小。我希望这两个按钮位于组框内部的相同相对位置。

Fresh instance without resizing.

当我向左或向右调整表单大小时它起作用,但是当我向上或向下调整它时,按钮的移动速度似乎比组框中的其他控件慢。

Making form larger

Making form smaller

这是相关的设计器代码:

// 
// groupBox1
//
this.groupBox1.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.groupBox1.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.groupBox1.Controls.Add(this.button_delete);
this.groupBox1.Controls.Add(this.button_add);
this.groupBox1.Controls.Add(this.list_files);
this.groupBox1.Font = new System.Drawing.Font("Lucida Console", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.groupBox1.Location = new System.Drawing.Point(13, 42);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(502, 297);
this.groupBox1.TabIndex = 0;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "Audio";
//
// list_files
//
this.list_files.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.list_files.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.list_files.GridLines = true;
this.list_files.Location = new System.Drawing.Point(7, 18);
this.list_files.Name = "list_files";
this.list_files.Size = new System.Drawing.Size(489, 239);
this.list_files.TabIndex = 0;
this.list_files.UseCompatibleStateImageBehavior = false;
this.list_files.View = System.Windows.Forms.View.List;
//
// button_add
//
this.button_add.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
this.button_add.Location = new System.Drawing.Point(7, 264);
this.button_add.MaximumSize = new System.Drawing.Size(75, 23);
this.button_add.MinimumSize = new System.Drawing.Size(75, 23);
this.button_add.Name = "button_add";
this.button_add.Size = new System.Drawing.Size(75, 23);
this.button_add.TabIndex = 1;
this.button_add.Text = "Add File";
this.button_add.UseVisualStyleBackColor = true;
this.button_add.Click += new System.EventHandler(this.button_add_Click);
//
// button_delete
//
this.button_delete.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
this.button_delete.Location = new System.Drawing.Point(88, 264);
this.button_delete.MaximumSize = new System.Drawing.Size(91, 23);
this.button_delete.MinimumSize = new System.Drawing.Size(91, 23);
this.button_delete.Name = "button_delete";
this.button_delete.Size = new System.Drawing.Size(91, 23);
this.button_delete.TabIndex = 2;
this.button_delete.Text = "Remove File";
this.button_delete.UseVisualStyleBackColor = true;
this.button_delete.Click += new System.EventHandler(this.button_delete_Click);

最佳答案

尝试将按钮固定在左侧和底部。看起来您正在左右锚定它们。

关于c# - 按钮 anchor 的重新定位不如组中的其他控件快,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38237992/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com