我创建了一个处理表单控制跟踪的 formControlTracker 类。这似乎按预期工作。现在,我想在按下保存按钮时从 formControlTracker 类中访问 public string[] getDirtyControls() 方法。我试图访问 cTracker.getDirtyControls(), 总线作为代码代表,我认为我实例化的类 formControlTracker 超出了范围。如何在无需重新实例化 formControlTracker 类的情况下访问 getDirtyControls() 方法?
代码片段:
public partial class settingsForm : Form
{
public settingsForm()
{
InitializeComponent();
settingsTabControl.Appearance = TabAppearance.Buttons;
settingsTabControl.SizeMode = TabSizeMode.Fixed;
settingsTabControl.ItemSize = new System.Drawing.Size(0,1);
formControlTracker cTracker = new formControlTracker(this);
wLogSettingsFormProperties settingsFormProp = new wLogSettingsFormProperties();
}
public void lDirtyControls()
{
/*foreach (string con in cTracker.getDirtyControls())
{
MessageBox.Show(con);
}*/
}
public void saveSettingsButton_Click(object sender, EventArgs e)
{
lDirtyControls();
}