Skip to content

Instantly share code, notes, and snippets.

@decvalts
Last active April 27, 2016 19:21
Show Gist options
  • Select an option

  • Save decvalts/98feea440bf5b8e31496834c9e6c2e23 to your computer and use it in GitHub Desktop.

Select an option

Save decvalts/98feea440bf5b8e31496834c9e6c2e23 to your computer and use it in GitHub Desktop.
CAESAR-Lisflood error : An object reference is required for the non-static field, method, or property
// In Form2.cs, line 23
private void Form2_Leave(object sender, EventArgs e)
{
caesar1.Form1.checkBox2.Checked = false;
}
// Should be...
private void Form2_Leave(object sender, EventArgs e)
{
caesar1.Form1 Frm1 = new caesar1.Form1();
Frm1.checkBox2.Checked = false;
}
// Similarly in ZoomPanImageBox.cs, line 164
private void clicky(object sender, MouseEventArgs e)
{
if (caesar1.Form1.checkBox2.Checked == true)
{ ...
// Should be...
private void clicky(object sender, MouseEventArgs e)
{
caesar1.Form1 Frm1 = new caesar1.Form1();
if (Frm1.checkBox2.Checked == true)
{ ...
// Now fix the checkbox2 issue by making it static
// line 1268
public static CheckBox checkBox2;
// Now you have to make all the instances of this.checkbox2 into caesar1.Form1.checkbox2...
// line 1720
caesar1.Form1.checkBox2 = new System.Windows.Forms.CheckBox();
// lines 5120 - 5128
caesar1.Form1.checkBox2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
caesar1.Form1.checkBox2.AutoSize = true;
caesar1.Form1.checkBox2.Location = new System.Drawing.Point(407, 543);
caesar1.Form1.checkBox2.Name = "checkBox2";
caesar1.Form1.checkBox2.Size = new System.Drawing.Size(108, 17);
caesar1.Form1.checkBox2.TabIndex = 151;
caesar1.Form1.checkBox2.Text = "point info window";
caesar1.Form1.checkBox2.UseVisualStyleBackColor = true;
caesar1.Form1.checkBox2.CheckedChanged += new System.EventHandler(this.checkBox2_CheckedChanged);
// line 5280
this.Controls.Add(caesar1.Form1.checkBox2);
@decvalts
Copy link
Copy Markdown
Author

Build from source resulted in error:
In Visual Studio Express

An object reference is required for the non-static field, method, or property 'caesar1.Form1.checkBox2' Form2.cs
An object reference is required for the non-static field, method, or property 'caesar1.Form1.checkBox2' ZoomPanImageBox.cs

@decvalts
Copy link
Copy Markdown
Author

Ahh...but that caused the point info window to get buggy...NullReferenceException when you try to query cells.

@decvalts
Copy link
Copy Markdown
Author

Make all the this.checkBox2 into caesar1.Form1.checkbox2 seems to do the trick

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment