【发布时间】:2021-09-16 05:07:30
【问题描述】:
我想通过使用单独的类“Delete”和方法 .resetText() 从 TextBox 'txtName' 中删除值。 我无法在这个单独的类中访问我的 TextBox。 我该如何解决这个问题?
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public void butDelete_Click(object sender, EventArgs e)
{
Delete delete = new Delete();
}
}
class Delete
{
public Delete()
{
txtName.ResetText();
}
}
【问题讨论】:
-
您可以将文本框对象作为参数传递
标签: c# visual-studio winforms class textbox