0

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.

  • Does this answer your question? [Communicate between two windows forms in C#](https://stackoverflow.com/questions/1665533/communicate-between-two-windows-forms-in-c-sharp) – JohnG Mar 21 '22 at 15:58
  • I think I should probably add, I don't know c# at all, I've been using tutorials on youtube. I'm looking for something I can basically copy and paste into my code – ShadySpiritomb Mar 22 '22 at 18:40
  • Sorry but I have to ask… if you do NOT know C#, then why are you doing this? Are you familiar with any programming languages? – JohnG Mar 23 '22 at 03:18
  • It's a project I need to do for school, and we aren't allowed much help, we were basically just told "I hope you know c# because you need it now". I'm not really familiar with any programming languages other than the basics (and I mean basics) of python – ShadySpiritomb Mar 23 '22 at 18:21
  • Well… I do not know what to tell you. If you are in a class where you need to know C# and you do not know C#, then maybe you are in the wrong class? In other words, if the teacher told you that you need to know C#, and you do not know C#, then why did you take the class? – JohnG Mar 24 '22 at 03:25
  • I expected the teacher to teach us c# or something. It doesn't matter now, i got someone else to do it for me – ShadySpiritomb Mar 24 '22 at 18:19

1 Answers1

0

As a variant you can save selectedItem to String/StringCollection, then to app settings(Settings.Default). And on another form get this value back.

NG-Designs
  • 11
  • 3