任何控制。但最好是全部(TextBox、Panel、Button、LinkLabel、TabControl 等)。我想做的是:
public class Something
{
public String isBetterThan { get; set; }
public String Author { get; set; }
}
public void button1_Click(object sender, EventArgs e)
{
panelControl1.ClassObject = new Something()
{
isBetterThan = "nothing.",
Author = "Unknown"
};
}
因此,从上面的代码中,您可以看到它的行为类似于 .Location 属性,您可以在其中为其分配一个新值。我想存储这些信息,以便以后,我可以简单地这样做:
public void getClassDetailsButton_Click(object sender, EventArgs e)
{
Something something = (Something)panelControl1.ClassObject;
MessageBox.Show("Something is better than " + something.isBetterThan);
}