表格只会增加大小 [英] Form will only increase in size

查看:67
本文介绍了表格只会增加大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的表单,上面只有几个控件.它将调整大小,但只会增加大小.怎么了?

I have a simple form that has only a few controls on it. It will resize but only increase in size. What it up?

private void InitializeComponent()
{
  System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormDisplayResults));
  this.dataGrid = new System.Windows.Forms.DataGridView();
  this.panel1 = new System.Windows.Forms.Panel();
  this.statusIcon = new System.Windows.Forms.PictureBox();
  this.lableStatus = new System.Windows.Forms.Label();
  this.buttonOk = new System.Windows.Forms.Button();
  this.buttonCancel = new System.Windows.Forms.Button();
  ((System.ComponentModel.ISupportInitialize)(this.dataGrid)).BeginInit();
  this.panel1.SuspendLayout();
  ((System.ComponentModel.ISupportInitialize)(this.statusIcon)).BeginInit();
  this.SuspendLayout();
  //
  // dataGrid
  //
  this.dataGrid.AllowUserToAddRows = false;
  this.dataGrid.AllowUserToDeleteRows = false;
  this.dataGrid.AllowUserToOrderColumns = true;
  this.dataGrid.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.AllCells;
  this.dataGrid.AutoSizeRowsMode = System.Windows.Forms.DataGridViewAutoSizeRowsMode.AllCells;
  this.dataGrid.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
  this.dataGrid.Dock = System.Windows.Forms.DockStyle.Fill;
  this.dataGrid.Location = new System.Drawing.Point(0, 0);
  this.dataGrid.Name = "dataGrid";
  this.dataGrid.ReadOnly = true;
  this.dataGrid.RowHeadersWidthSizeMode = System.Windows.Forms.DataGridViewRowHeadersWidthSizeMode.AutoSizeToAllHeaders;
  this.dataGrid.Size = new System.Drawing.Size(976, 572);
  this.dataGrid.TabIndex = 0;
  this.dataGrid.TabStop = false;
  //
  // panel1
  //
  this.panel1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
        | System.Windows.Forms.AnchorStyles.Right)));
  this.panel1.Controls.Add(this.statusIcon);
  this.panel1.Controls.Add(this.lableStatus);
  this.panel1.Controls.Add(this.buttonOk);
  this.panel1.Controls.Add(this.buttonCancel);
  this.panel1.Location = new System.Drawing.Point(0, 547);
  this.panel1.Margin = new System.Windows.Forms.Padding(5, 10, 5, 10);
  this.panel1.Name = "panel1";
  this.panel1.Size = new System.Drawing.Size(976, 25);
  this.panel1.TabIndex = 1;
  //
  // statusIcon
  //
  this.statusIcon.Image = ((System.Drawing.Image)(resources.GetObject("statusIcon.Image")));
  this.statusIcon.Location = new System.Drawing.Point(0, 0);
  this.statusIcon.Name = "statusIcon";
  this.statusIcon.Size = new System.Drawing.Size(24, 24);
  this.statusIcon.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
  this.statusIcon.TabIndex = 3;
  this.statusIcon.TabStop = false;
  //
  // lableStatus
  //
  this.lableStatus.AutoSize = true;
  this.lableStatus.Location = new System.Drawing.Point(32, 6);
  this.lableStatus.Margin = new System.Windows.Forms.Padding(5, 10, 5, 10);
  this.lableStatus.Name = "lableStatus";
  this.lableStatus.Size = new System.Drawing.Size(28, 13);
  this.lableStatus.TabIndex = 2;
  this.lableStatus.Text = "Text";
  //
  // buttonOk
  //
  this.buttonOk.Dock = System.Windows.Forms.DockStyle.Right;
  this.buttonOk.Location = new System.Drawing.Point(828, 0);
  this.buttonOk.Name = "buttonOk";
  this.buttonOk.Size = new System.Drawing.Size(73, 25);
  this.buttonOk.TabIndex = 1;
  this.buttonOk.Text = "Submit";
  this.buttonOk.UseVisualStyleBackColor = true;
  this.buttonOk.Click += new System.EventHandler(this.buttonOk_Click);
  //
  // buttonCancel
  //
  this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
  this.buttonCancel.Dock = System.Windows.Forms.DockStyle.Right;
  this.buttonCancel.Location = new System.Drawing.Point(901, 0);
  this.buttonCancel.Margin = new System.Windows.Forms.Padding(5);
  this.buttonCancel.Name = "buttonCancel";
  this.buttonCancel.Size = new System.Drawing.Size(75, 25);
  this.buttonCancel.TabIndex = 0;
  this.buttonCancel.Text = "Cancel";
  this.buttonCancel.UseVisualStyleBackColor = true;
  this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
  //
  // FormDisplayResults
  //
  this.AcceptButton = this.buttonOk;
  this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
  this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
  this.AutoSize = true;
  this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
  this.CancelButton = this.buttonCancel;
  this.CausesValidation = false;
  this.ClientSize = new System.Drawing.Size(976, 572);
  this.ControlBox = false;
  this.Controls.Add(this.panel1);
  this.Controls.Add(this.dataGrid);
  this.Name = "FormDisplayResults";
  this.Text = "Display Results";
  ((System.ComponentModel.ISupportInitialize)(this.dataGrid)).EndInit();
  this.panel1.ResumeLayout(false);
  this.panel1.PerformLayout();
  ((System.ComponentModel.ISupportInitialize)(this.statusIcon)).EndInit();
  this.ResumeLayout(false);

}

推荐答案

我希望这会解决有关AutoSizing的复杂性的问题,但是也许您只是在无意中将AutoSize设置在主窗体上.

艾伦!
I was hoping that this was going to a problem about the complexities of AutoSizing, but perhaps you have just inadvertantly set AutoSize on the main form.

Alan!


这篇关于表格只会增加大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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