C#状态栏设计丢失的恢复方法
程序症状:
由于状态栏图片资源丢,造成程序出错,进而造成以前设计的状态栏全部无显示。
解决办法:
1)在窗体属性下拉列表框内可以找以前设计的控件,复制一个控件名。
2)打开程序的查找对话框粘贴查到查找里,找整个解决方案,可以在窗体的xxx..Designer.cs找到控件的布局。
3)在每一个控件布局下加
this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.控件名});
列如:
//
// toolStripStatusLabel1
//
this.toolStripStatusLabel1.AutoSize = false;
this.toolStripStatusLabel1.Name = "toolStripStatusLabel1";
this.toolStripStatusLabel1.Size = new System.Drawing.Size(71, 17);
this.toolStripStatusLabel1.Text = "站点连接数:";
this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.toolStripStatusLabel1});
切出xxx..Designer.cs窗口时,程序会自动整理成4)的样式。
4)也可以在控件布局下面找到
//
// statusStrip1 --状态栏名称
//
在它下面整体添加如下:
this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.toolStripStatusLabel1,
this.Status2,
this.toolStripStatusLabel4,
this.toolStripStatusLabel6,
this.toolStripStatusLabel2,
this.toolStripStatusLabel3,
this.toolStripStatusLabel5,
this.toolStripStatusLabel7,
this.toolStripDropDownButton1,
this.toolStripDropDownButton2,
this.toolStripComboBox1,
this.toolStripStatusLabel9,
this.toolStripStatusLabel8,
this.toolStripStatusLabel10});
5)切回状态栏窗体,会看到所有设置都回来了。
6)测试环境vs2010 C#,其它版本没测试,估计类似。