如何以另一种形式使用组合框中的数据c#
我正在用 C#(Visual Studio、Windows 窗体)编写一个程序,其中涉及用户从组合框中选择一个名称,然后单击一个按钮,将他们带到另一个窗体上的测验。我希望在测验结束时创建一个文本文件,显示所选名称和测验结果,后跟“~”符号。
老实说,我不知道从哪里开始。我正在使用流阅读器。
这是我用于组合框和将您发送到下一个表单的按钮的代码
private void quizSelectPupilCB_SelectedIndexChanged(object sender, EventArgs e)
{
selectedClass = quizSelectPupilCB.SelectedItem.ToString();
}
private void quizStartBTN_Click(object sender, EventArgs e)
{
Quiz2 formQuiz2 = new Quiz2();
formQuiz2.Show();
this.Hide();
}
如何在另一个表单上使用此数据?
我什至不知道从哪里开始。我尝试查找诸如“如何从一种表单访问数据并将其放入另一个 c# 中”之类的内容以及类似的内容,但我发现的所有内容要么不是我想要的,要么是以一种非常令人困惑的方式措辞的。
I'm writing a program in c# (visual studio, windows forms) which involves the user selecting a name from a combo box, and then clicking a button which brings them to a quiz on another form. I want a text file to be created at the end of the quiz showing the name selected and the quiz results, followed by a "~" symbol.
I honestly don't know where to start. I'm using stream reader.
This is the code I used for the combo box and the button that sends you to the next form
private void quizSelectPupilCB_SelectedIndexChanged(object sender, EventArgs e)
{
selectedClass = quizSelectPupilCB.SelectedItem.ToString();
}
private void quizStartBTN_Click(object sender, EventArgs e)
{
Quiz2 formQuiz2 = new Quiz2();
formQuiz2.Show();
this.Hide();
}
How do I use this data on another form?
I don't even know where to start. I tried looking up things like "how to access data from one form and put it in another c#" and similar things but everything I found was either not what I was looking for, or worded in a really confusing way.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
作为一种变体,您可以将 selectedItem 保存到 String/StringCollection,然后保存到应用程序设置(Settings.Default)。并在另一种形式上取回该值。
As a variant you can save selectedItem to String/StringCollection, then to app settings(Settings.Default). And on another form get this value back.