到目前为止,如果用户输入内容,我将存储在标签属性中。我知道这是不对的。我如何根据用户输入更新变量,以便在需要使用它的任何事件中使用?将用户输入保存为c#windows窗体中的变量
这是我尝试过的很多事情之一。我甚至无法找出正确的搜索条件来搜索我需要做的解决方案。
namespace Words
{
public partial class formWords : Form
{
int x = 5;
int y = 50;
int buttonWidth = 120;
int buttonHeight = 40;
string fileList = "";
string word = "";
string wordFolderPath = @"C:\words\";// this is the variable I want to change with the dialog box below.
private void selectWordFolderToolStripMenuItem_Click(object sender, EventArgs e)
{
FolderBrowserDialog folder = new FolderBrowserDialog();
if (folder.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
string folderPath = folder.SelectedPath;
formWords.wordFolderPath = folderPath;
}
}
我认为这比以前复杂得多。谢谢。 –