C# custom control: use custom control prompt ----- variable "cameraControl1" is not declared or has never been assigned a value.

I. Overview

When using the custom control cameraControl, the form using the custom control appears: the variable "cameraControl1" is not declared or has never been assigned a value. As follows:

 

2. Problem analysis:

According to the error prompt, click to the wrong place,

 

 find the wrong line

Select the variable cameraControl1, right-click, and select Go to Definition

 The variable cameraControl1 is defined as follows:

 

 3. Solutions:

1. Create a new object for the defined variable cameraControl1

before fixing:

After modification:

 

 

before code modification

private cameraControl cameraControl1;

After code modification

        private cameraControl cameraControl1()
        {
            Zimo.JinDun.cameraControl cameraControl1 = new Zimo.JinDun.cameraControl();
            return cameraControl1;
        }

2. Change the corresponding this.cameraControl1 to this.cameraControl1()

before fixing:

 after modification

 3. If there is, log out, as shown below:

Before logout:

 After logout:

 

Guess you like

Origin blog.csdn.net/chentiebo/article/details/130945650