表单上的所有控件都是不可见的
我遇到了一个奇怪的问题。 只给出了这个代码(我已经减少了基本要素),表单将会出现但是它上面的所有控件都是不可见的,即使它们各自的Visible
属性都是真的:
static class Program { [STAThread] static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new WaveformWindow()); } } // ... public partial class WaveformWindow : Form { public WaveformWindow() { InitializeComponent(); } } // ... partial class WaveformWindow { /// /// Required designer variable. /// private System.ComponentModel.IContainer components = null; /// /// Clean up any resources being used. /// /// true if managed resources should be disposed; otherwise, false. protected override void Dispose(bool disposing) { if (disposing && (components != null)) { components.Dispose(); } base.Dispose(disposing); } #region Windows Form Designer generated code /// /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// private void InitializeComponent() { this.label1 = new System.Windows.Forms.Label(); this.SuspendLayout(); // // label1 // this.label1.AutoSize = true; this.label1.Location = new System.Drawing.Point(27, 27); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(35, 13); this.label1.TabIndex = 4; this.label1.Text = "label1"; // // WaveformWindow // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(398, 373); this.Name = "WaveformWindow"; this.ShowInTaskbar = false; this.Text = "WaveformWindow"; this.ResumeLayout(false); } #endregion private System.Windows.Forms.Label label1; }
比较非剥离程序的工作版本和损坏版本,唯一更改的文件是表单设计器文件。
将控件添加到窗体以使其可见。 见…… this.Controls.Add(this.label1); 下面
// // WaveformWindow // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(398, 373); this.Name = "WaveformWindow"; this.ShowInTaskbar = false; this.Text = "WaveformWindow"; **this.Controls.Add(this.label1);** this.ResumeLayout(false);
Windows窗体生成代码以自动将所有控件添加到窗体。 因此,无论何时遇到此类问题,请删除旧控件并再次拖放它。 它必须是可见的。 (编辑以了解问题)
- 安装CORS后无法加载文件
- 使用LINQ,如何从List中找到具有给定属性值的对象?
- NHibernate.Mapping.ByCode.Conformist.ClassMapping和FluentNHibernate.Mapping.ClassMap有什么区别?
- 阅读带有双引号的csv与lumenwork csv阅读器
- EPPlus是否要求在服务器上安装Excel?
- 是否可以创建一个通用的按位枚举’IsOptionSet()’方法?
- NHibernate查询,按时间戳字段过滤
- 如何为.NET应用程序域重新加载程序集?
- Windows Vista:无法加载DLL“x.dll”:对内存位置的无效访问。 (DllNotFoundException)