我使用按钮和复选框来创建表单。如果我打按钮静态无效被称为其调用非静态无效,显示消息框与checkbox.checked.toString() 的问题是,如果我改变复选框值它总是显示虚假C#从静态访问控制属性void
代码是
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsApplication2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
public void y()
{
MessageBox.Show(checkBox1.Checked.ToString());
}
static void x()
{
Form1 f = new Form1();
f.y();
}
private void button1_Click(object sender, EventArgs e)
{
x();
}
}
}
当然,如果他这样做,x也可能是一个静态方法,所以他不必传入表单对象。 – Powerlord 2009-02-27 15:12:49
补充说,谢谢! – chakrit 2009-02-27 15:33:47