C#winform控件突然消失解决办法

  在进行开发简易串口助手时,在看视频照着开发时,回头发现vs中的控件全部消失隐藏不见了,再拖入新的控件后发现之前的控件并未消失,只是看不见了,翻了一下CSDN,发现很多简略得几句话带过来,于是自己观察代码,发现了因为几行代码的消失引起的控件消失,将自己的大概解决过程通过此篇文章分享一下,如有不对请多指教。

  具体问题出在画红线这个文件中

   然后我经过跟控件未消失代码进行比对会发现画圈代码消失了,上方的画圈代码直接进行补全即可,下方的补全几行即可

this.components = new System.ComponentModel.Container();
this.radioButton1 = new System.Windows.Forms.RadioButton();
this.radioButton2 = new System.Windows.Forms.RadioButton();
this.radioButton3 = new System.Windows.Forms.RadioButton();
this.radioButton4 = new System.Windows.Forms.RadioButton();
this.panel1 = new System.Windows.Forms.Panel();
this.panel2 = new System.Windows.Forms.Panel();
this.textBox1 = new System.Windows.Forms.TextBox();
this.textBox2 = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.comboBox1 = new System.Windows.Forms.ComboBox();
this.comboBox2 = new System.Windows.Forms.ComboBox();
this.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.button3 = new System.Windows.Forms.Button();
this.serialPort1 = new System.IO.Ports.SerialPort(this.components);
this.panel1.SuspendLayout();
this.panel2.SuspendLayout();
this.SuspendLayout();
/*这个按照自己所缺失的控件进行补全即可*/
this.radioButton1.AutoSize = true;
this.radioButton1.Location = new System.Drawing.Point(3, 13);
this.radioButton1.Name = "radioButton1";
this.radioButton1.Size = new System.Drawing.Size(58, 19);
this.radioButton1.TabIndex = 0;
this.radioButton1.TabStop = true;
this.radioButton1.Text = "数值";
this.radioButton1.UseVisualStyleBackColor = true;
/* 不用全部补全,仅补全几行运行之后控件便会重新回来*/

   在代码最后几行再将这些Add上去,像如图

   第一张图片下方画圈的代码具体跟控件的属性什么的有关,而且不同的控件也并不相同,很难自己去独立补全这些,但是只补全几行后Add之后,重新进行编译运行,便可以发现winform控件重新出现(但有可能没有什么颜色,跟补全的属性什么有关大概),需要在窗体各个地方点一下,便会发现,再点回这个文件发现没补全的几行代码也会重新出现。

  具体为什么winform控件会突然消失这一问题并不是很清楚,希望有大佬能说明一下。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

kld。

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值