C # constructor error

I'm new to C #, so please excuse me if I ask stupid questions ...

Here is my problem:

  • I have a class "ProtocolTabPage" that inherits from "TabPage".
  • I have a "ControlPanel" that inherits from the "Panel".
  • I have a ControlPanel created using ProtocolTabPage.
  • Both of my classes are in the namespace "AutoTestProtocols.Interface".

In ProtocolTabPage [Design], I have the following errors:

The "ProtocolPanel" variable is either not declared or has never been assigned.

in System.ComponentModel.Design.Serialization.CodeDomSerializerBase.Error (manager IDesignerSerializationManager, String exceptionText, String helpLink) in System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeExpression name (IDesignerSerializationManager Codeponent name, Manager code, String .Serialization.CodeDomSerializerBase.DeserializeExpression (IDesignerSerializationManager manager, String name, CodeExpression expression) in System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeStatement (IDesignerSerializationManager manager, CodeStatement operator) "

Although in my protocol ProtocolTabPage.Designer I have

[...]
this.ProtocolPanel = new AutoTestProtocols.Interface.ControlPanel();
[...]
this.splitContainer1.Panel2.Controls.Add(this.ProtocolPanel);
[...]
this.ProtocolPanel.AutoScroll = true;
this.ProtocolPanel.Dock = System.Windows.Forms.DockStyle.Fill;
this.ProtocolPanel.Location = new System.Drawing.Point(0, 0);
this.ProtocolPanel.Name = "ProtocolPanel";
this.ProtocolPanel.Size = new System.Drawing.Size(696, 700);
this.ProtocolPanel.TabIndex = 0;
[...]
private AutoTestProtocols.Interface.ControlPanel ProtocolPanel;"

What's wrong?

+3
source share
4

, , , . ProtocolPanel :

ProtocolPanel myProtocolPanel = new AutoTestProtocols.Interface.ControlPanel();

"This.ProtocolPanel" "myProtocolPanel".

+1

5 ... , , , , .Net , / gui.

:

[Browsable(false)]
ProtocolPanel ProtocolPanel {get {...} set {...} }

, resx "" (). "" , - , ProtocolPanel, . , .

+1

, :
ProtocolPanel - , . , , , ? , ?

, , . , :

if (DesignMode || LicenseManager.UsageMode == LicenseUsageMode.Designtime)
{               
    return;   //in design mode do not initialize anything (accessing the model here may cause troubles)
}
0

*.resx. String1 . ( Visual Studio 2010)

  • *.resx
  • Select a row from the drop-down list.
  • Right-click String1 and select Delete
  • OK to save, then close * .resx and open the form again.
0
source

Source: https://habr.com/ru/post/1707932/


All Articles