繁体   English   中英

C#程序txtbox和combox以及windowform中的所有内容都不合适吗?

[英]C# program txtbox and combox and everything in windowform is out of place?

我已经创建了一个程序,它可以在我的PC上流畅运行,并且一切都像在VS中一样,但是当我在另一台PC上运行它时,每个文本框和标签以及所有内容均不在其正确的位置,它们似乎都不合适从他们所在的地方。 我厌倦了锁定,但也没有运气,而且在调试和运行后,我在Visual Studio中无法真正看到(或制成)正确的位置:(即使在我的PC中(但仍比在其他PC中运行更好))我完全迷失了自己,我很累,无法重新创建,因为这是我的项目,我已经没时间了。

我只想知道为什么以及如何锁定所有标签和文本框以及Windows窗体和usercontorl中的所有内容。

这是在VS中制作时

http://s9.postimage.org/rvxsa9jul/image.jpg

这是我在我的电脑中调试后

http://s9.postimage.org/ipfhmzem5/image.jpg我希望你们能解决我的问题

这是mt usercontrol.cs上的designer.cs

你的意思是designer.cs,这是

partial class Reservation
    {
        ///  
        /// Required designer variable.
        /// 
        private System.ComponentModel.IContainer components = null;

/// <summary> /// Clean up any resources being used. /// </summary> /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> protected override void Dispose(bool disposing) { if (disposing && (components != null)) { components.Dispose(); } base.Dispose(disposing); } #region Component 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.Agetxt = new System.Windows.Forms.TextBox(); this.label8 = new System.Windows.Forms.Label(); this.Addresstxt = new System.Windows.Forms.TextBox(); this.label7 = new System.Windows.Forms.Label(); this.Occupationtxt = new System.Windows.Forms.TextBox(); this.label6 = new System.Windows.Forms.Label(); this.PhoneNoTxt = new System.Windows.Forms.TextBox(); this.label5 = new System.Windows.Forms.Label(); this.MarriedcomboBox = new System.Windows.Forms.ComboBox(); this.label4 = new System.Windows.Forms.Label(); this.SexComboBox = new System.Windows.Forms.ComboBox(); this.label3 = new System.Windows.Forms.Label(); this.LastNametxt = new System.Windows.Forms.TextBox(); this.label2 = new System.Windows.Forms.Label(); this.FirstNametxt = new System.Windows.Forms.TextBox(); this.label1 = new System.Windows.Forms.Label(); this.label9 = new System.Windows.Forms.Label(); this.ReasonForStayingtxt = new System.Windows.Forms.TextBox(); this.label10 = new System.Windows.Forms.Label(); this.NoOfAdultstxt = new System.Windows.Forms.TextBox(); this.label11 = new System.Windows.Forms.Label(); this.NoOfChildrentxt = new System.Windows.Forms.TextBox(); this.label12 = new System.Windows.Forms.Label(); this.NoOfDaysToStaytxt = new System.Windows.Forms.TextBox(); this.label13 = new System.Windows.Forms.Label(); this.RoomTypeComboBox = new System.Windows.Forms.ComboBox(); this.label14 = new System.Windows.Forms.Label(); this.textBox1 = new System.Windows.Forms.TextBox(); this.SuspendLayout(); // // Agetxt // this.Agetxt.Anchor = System.Windows.Forms.AnchorStyles.Left; this.Agetxt.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.Agetxt.Location = new System.Drawing.Point(70, 162); this.Agetxt.MaxLength = 3; this.Agetxt.Name = "Agetxt"; this.Agetxt.Size = new System.Drawing.Size(75, 22); this.Agetxt.TabIndex = 15; // // label8 // this.label8.Anchor = System.Windows.Forms.AnchorStyles.Left; this.label8.AutoSize = true; this.label8.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.label8.Location = new System.Drawing.Point(24, 165); this.label8.Name = "label8"; this.label8.Size = new System.Drawing.Size(33, 16); this.label8.TabIndex = 14; this.label8.Text = "Age"; // // Addresstxt // this.Addresstxt.Anchor = System.Windows.Forms.AnchorStyles.Left; this.Addresstxt.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.Addresstxt.Location = new System.Drawing.Point(71, 219); this.Addresstxt.Multiline = true; this.Addresstxt.Name = "Addresstxt"; this.Addresstxt.Size = new System.Drawing.Size(251, 72); this.Addresstxt.TabIndex = 13; // // label7 // this.label7.AutoSize = true; this.label7.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.label7.Location = new System.Drawing.Point(14, 234); this.label7.Name = "label7"; this.label7.Size = new System.Drawing.Size(59, 16); this.label7.TabIndex = 12; this.label7.Text = "Address"; // // Occupationtxt // this.Occupationtxt.Anchor = System.Windows.Forms.AnchorStyles.Left; this.Occupationtxt.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.Occupationtxt.Location = new System.Drawing.Point(230, 192); this.Occupationtxt.Name = "Occupationtxt"; this.Occupationtxt.Size = new System.Drawing.Size(92, 22); this.Occupationtxt.TabIndex = 11; // // label6 // this.label6.Anchor = System.Windows.Forms.AnchorStyles.Left; this.label6.AutoSize = true; this.label6.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.label6.Location = new System.Drawing.Point(161, 192); this.label6.Name = "label6"; this.label6.Size = new System.Drawing.Size(76, 16); this.label6.TabIndex = 10; this.label6.Text = "Occupation"; // // PhoneNoTxt // this.PhoneNoTxt.Anchor = System.Windows.Forms.AnchorStyles.Left; this.PhoneNoTxt.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.PhoneNoTxt.Location = new System.Drawing.Point(71, 189); this.PhoneNoTxt.MaxLength = 15; this.PhoneNoTxt.Name = "PhoneNoTxt"; this.PhoneNoTxt.Size = new System.Drawing.Size(74, 22); this.PhoneNoTxt.TabIndex = 9; // // label5 // this.label5.Anchor = System.Windows.Forms.AnchorStyles.Left; this.label5.AutoSize = true; this.label5.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.label5.Location = new System.Drawing.Point(5, 192); this.label5.Name = "label5"; this.label5.Size = new System.Drawing.Size(71, 16); this.label5.TabIndex = 8; this.label5.Text = "Phone No."; // // MarriedcomboBox // this.MarriedcomboBox.Anchor = System.Windows.Forms.AnchorStyles.Left; this.MarriedcomboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.MarriedcomboBox.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.MarriedcomboBox.FormattingEnabled = true; this.MarriedcomboBox.Items.AddRange(new object[] { "Married", "Unmarried"}); this.MarriedcomboBox.Location = new System.Drawing.Point(230, 130); this.MarriedcomboBox.Name = "MarriedcomboBox"; this.MarriedcomboBox.Size = new System.Drawing.Size(92, 24); this.MarriedcomboBox.TabIndex = 7; // // label4 // this.label4.Anchor = System.Windows.Forms.AnchorStyles.Left; this.label4.AutoSize = true; this.label4.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.label4.Location = new System.Drawing.Point(161, 133); this.label4.Name = "label4"; this.label4.Size = new System.Drawing.Size(102, 16); this.label4.TabIndex = 6; this.label4.Text = "Marriage Status"; // // SexComboBox // this.SexComboBox.Anchor = System.Windows.Forms.AnchorStyles.Left; this.SexComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.SexComboBox.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.SexComboBox.FormattingEnabled = true; this.SexComboBox.Items.AddRange(new object[] { "Female", "Male"}); this.SexComboBox.Location = new System.Drawing.Point(70, 130); this.SexComboBox.Name = "SexComboBox"; this.SexComboBox.Size = new System.Drawing.Size(74, 24); this.SexComboBox.Sorted = true; this.SexComboBox.TabIndex = 5; // // label3 // this.label3.Anchor = System.Windows.Forms.AnchorStyles.Left; this.label3.AutoSize = true; this.label3.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.label3.Location = new System.Drawing.Point(25, 133); this.label3.Name = "label3"; this.label3.Size = new System.Drawing.Size(31, 16); this.label3.TabIndex = 4; this.label3.Text = "Sex"; // // LastNametxt // this.LastNametxt.Anchor = System.Windows.Forms.AnchorStyles.Left; this.LastNametxt.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.LastNametxt.Location = new System.Drawing.Point(229, 103); this.LastNametxt.Name = "LastNametxt"; this.LastNametxt.Size = new System.Drawing.Size(92, 22); this.LastNametxt.TabIndex = 3; // // label2 // this.label2.Anchor = System.Windows.Forms.AnchorStyles.Left; this.label2.AutoSize = true; this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.label2.Location = new System.Drawing.Point(162, 103); this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(73, 16); this.label2.TabIndex = 2; this.label2.Text = "Last Name"; // // FirstNametxt // this.FirstNametxt.Anchor = System.Windows.Forms.AnchorStyles.Left; this.FirstNametxt.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.FirstNametxt.Location = new System.Drawing.Point(70, 103); this.FirstNametxt.Name = "FirstNametxt"; this.FirstNametxt.Size = new System.Drawing.Size(92, 22); this.FirstNametxt.TabIndex = 1; // // label1 // this.label1.Anchor = System.Windows.Forms.AnchorStyles.Left; this.label1.AutoSize = true; this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.label1.Location = new System.Drawing.Point(3, 103); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(73, 16); this.label1.TabIndex = 0; this.label1.Text = "First Name"; // // label9 // this.label9.Anchor = System.Windows.Forms.AnchorStyles.Right; this.label9.AutoSize = true; this.label9.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.label9.Location = new System.Drawing.Point(380, 105); this.label9.Name = "label9"; this.label9.Size = new System.Drawing.Size(122, 16); this.label9.TabIndex = 16; this.label9.Text = "Reason for Staying"; // // ReasonForStayingtxt // this.ReasonForStayingtxt.Anchor = System.Windows.Forms.AnchorStyles.Right; this.ReasonForStayingtxt.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.ReasonForStayingtxt.Location = new System.Drawing.Point(483, 105); this.ReasonForStayingtxt.Multiline = true; this.ReasonForStayingtxt.Name = "ReasonForStayingtxt"; this.ReasonForStayingtxt.Size = new System.Drawing.Size(289, 94); this.ReasonForStayingtxt.TabIndex = 17; // // label10 // this.label10.Anchor = System.Windows.Forms.AnchorStyles.Right; this.label10.AutoSize = true; this.label10.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.label10.Location = new System.Drawing.Point(407, 231); this.label10.Name = "label10"; this.label10.Size = new System.Drawing.Size(85, 16); this.label10.TabIndex = 18; this.label10.Text = "No. Of Adults"; // // NoOfAdultstxt // this.NoOfAdultstxt.Anchor = System.Windows.Forms.AnchorStyles.Right; this.NoOfAdultstxt.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.NoOfAdultstxt.Location = new System.Drawing.Point(483, 224); this.NoOfAdultstxt.MaxLength = 3; this.NoOfAdultstxt.Name = "NoOfAdultstxt"; this.NoOfAdultstxt.Size = new System.Drawing.Size(84, 22); this.NoOfAdultstxt.TabIndex = 19; // // label11 // this.label11.Anchor = System.Windows.Forms.AnchorStyles.Right; this.label11.AutoSize = true; this.label11.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.label11.Location = new System.Drawing.Point(587, 231); this.label11.Name = "label11"; this.label11.Size = new System.Drawing.Size(97, 16); this.label11.TabIndex = 20; this.label11.Text = "No. Of Children"; // // NoOfChildrentxt // this.NoOfChildrentxt.Anchor = System.Windows.Forms.AnchorStyles.Right; this.NoOfChildrentxt.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.NoOfChildrentxt.Location = new System.Drawing.Point(672, 224); this.NoOfChildrentxt.MaxLength = 3; this.NoOfChildrentxt.Name = "NoOfChildrentxt"; this.NoOfChildrentxt.Size = new System.Drawing.Size(100, 22); this.NoOfChildrentxt.TabIndex = 21; // // label12 // this.label12.Anchor = System.Windows.Forms.AnchorStyles.Right; this.label12.AutoSize = true; this.label12.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.label12.Location = new System.Drawing.Point(407, 274); this.label12.Name = "label12"; this.label12.Size = new System.Drawing.Size(124, 16); this.label12.TabIndex = 22; this.label12.Text = "No. Of Days to Stay"; // // NoOfDaysToStaytxt // this.NoOfDaysToStaytxt.Anchor = System.Windows.Forms.AnchorStyles.Right; this.NoOfDaysToStaytxt.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.NoOfDaysToStaytxt.Location = new System.Drawing.Point(517, 267); this.NoOfDaysToStaytxt.MaxLength = 3; this.NoOfDaysToStaytxt.Name = "NoOfDaysToStaytxt"; this.NoOfDaysToStaytxt.Size = new System.Drawing.Size(50, 22); this.NoOfDaysToStaytxt.TabIndex = 23; // // label13 // this.label13.AutoSize = true; this.label13.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.label13.Location = new System.Drawing.Point(5, 311); this.label13.Name = "label13"; this.label13.Size = new System.Drawing.Size(80, 16); this.label13.TabIndex = 24; this.label13.Text = "Room Type"; // // RoomTypeComboBox // this.RoomTypeComboBox.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.RoomTypeComboBox.FormattingEnabled = true; this.RoomTypeComboBox.Location = new System.Drawing.Point(70, 308); this.RoomTypeComboBox.Name = "RoomTypeComboBox"; this.RoomTypeComboBox.Size = new System.Drawing.Size(121, 24); this.RoomTypeComboBox.TabIndex = 25; // // label14 // this.label14.Anchor = System.Windows.Forms.AnchorStyles.Right; this.label14.AutoSize = true; this.label14.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.27F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.label14.Location = new System.Drawing.Point(587, 270); this.label14.Name = "label14"; this.label14.Size = new System.Drawing.Size(86, 16); this.label14.TabIndex = 26; this.label14.Text = "Passport No."; // // textBox1 // this.textBox1.Anchor = System.Windows.Forms.AnchorStyles.Right; this.textBox1.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.27F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.textBox1.Location = new System.Drawing.Point(672, 267); this.textBox1.Name = "textBox1"; this.textBox1.Size = new System.Drawing.Size(100, 21); this.textBox1.TabIndex = 27; // // Reservation // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(204)))), ((int)(((byte)(204)))), ((int)(((byte)(255))))); this.Controls.Add(this.textBox1); this.Controls.Add(this.label14); this.Controls.Add(this.RoomTypeComboBox); this.Controls.Add(this.label13); this.Controls.Add(this.NoOfDaysToStaytxt); this.Controls.Add(this.label12); this.Controls.Add(this.NoOfChildrentxt); this.Controls.Add(this.label11); this.Controls.Add(this.NoOfAdultstxt); this.Controls.Add(this.label10); this.Controls.Add(this.ReasonForStayingtxt); this.Controls.Add(this.label9); this.Controls.Add(this.LastNametxt); this.Controls.Add(this.Agetxt); this.Controls.Add(this.label2); this.Controls.Add(this.FirstNametxt); this.Controls.Add(this.label1); this.Controls.Add(this.label8); this.Controls.Add(this.Addresstxt); this.Controls.Add(this.label3); this.Controls.Add(this.label7); this.Controls.Add(this.SexComboBox); this.Controls.Add(this.Occupationtxt); this.Controls.Add(this.label4); this.Controls.Add(this.label6); this.Controls.Add(this.MarriedcomboBox); this.Controls.Add(this.PhoneNoTxt); this.Controls.Add(this.label5); this.Name = "Reservation"; this.Size = new System.Drawing.Size(800, 600); this.ResumeLayout(false); this.PerformLayout(); } #endregion private System.Windows.Forms.TextBox PhoneNoTxt; private System.Windows.Forms.Label label5; private System.Windows.Forms.ComboBox SexComboBox; private System.Windows.Forms.Label label3; private System.Windows.Forms.TextBox FirstNametxt; private System.Windows.Forms.Label label1; private System.Windows.Forms.Label label7; private System.Windows.Forms.TextBox Agetxt; private System.Windows.Forms.Label label8; private System.Windows.Forms.ComboBox MarriedcomboBox; private System.Windows.Forms.Label label4; private System.Windows.Forms.TextBox LastNametxt; private System.Windows.Forms.Label label2; private System.Windows.Forms.TextBox Occupationtxt; private System.Windows.Forms.Label label6; private System.Windows.Forms.TextBox Addresstxt; private System.Windows.Forms.Label label9; private System.Windows.Forms.TextBox ReasonForStayingtxt; private System.Windows.Forms.Label label10; private System.Windows.Forms.TextBox NoOfAdultstxt; private System.Windows.Forms.Label label11; private System.Windows.Forms.TextBox NoOfChildrentxt; private System.Windows.Forms.Label label12; private System.Windows.Forms.TextBox NoOfDaysToStaytxt; private System.Windows.Forms.Label label13; private System.Windows.Forms.ComboBox RoomTypeComboBox; private System.Windows.Forms.Label label14; private System.Windows.Forms.TextBox textBox1; }

看起来您的控件锚不正确。

您能否将代码发布到设置锚点值/停靠值的位置。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM