What's new

C# Help in creating activity for multiple forms in c#

Bl4cksh33p

Journeyman
Joined
May 2, 2023
Posts
34
Reaction
4
Points
17
Pwede pa help ng pag gawa ng multiple forms application na activity?
they already created something like cghnaging the background color of a label, they also used menu toolstrip and creating a multiple forms applications with parent and child form. pwede bang pa help naman sa pag gawa ng panibagong activity with codes sana
 
Sure! I'd be happy to help you with creating a multiple forms application in C# with different activities. Can you provide more details on the specific activity you want to create?
 
TS Can you please provide more details about what you want to achieve in this new activity?
For example, what should be the functionality of the new form, what controls do you want to add, and what actions should they perform?
 
Sure! I'd be happy to help you with creating a multiple forms application in C# with different activities. Can you provide more details on the specific activity you want to create?
actually the whole concept is using multiple forms applications. as stated above the topics that we already made. and i cant think of anything already. i want an activity that still encorporates the topics that we have and a surprise factor
 
actually the whole concept is using multiple forms applications. as stated above the topics that we already made. and i cant think of anything already. i want an activity that still encorporates the topics that we have and a surprise factor
How about creating a quiz application using multiple forms? Here's a suggestion for the functionality of your quiz application:

1. The user selects the quiz category from the main menu (e.g. history, science, math).
2. The application loads a form specific to the selected quiz category. This form contains a list of questions and multiple choice answers.
3. The user selects their answer and clicks a "submit" button.
4. The application shows the user whether their answer is correct or incorrect.
5. The application moves on to the next question and repeats steps 3-4 until all questions in the quiz are answered.
6. At the end of the quiz, the application displays the user's score and gives them the option to retake the quiz or go back to the main menu.

To incorporate the topics you've already covered, you can use the menu toolstrip for the main menu and create separate forms for each quiz category as child forms. You can also use labels and buttons to display questions and answer choices, and change their properties (like the background color of a label) based on whether the answer is correct or incorrect.

Let me know if you have any questions or need help with the code!
 
How about creating a quiz application using multiple forms? Here's a suggestion for the functionality of your quiz application:

1. The user selects the quiz category from the main menu (e.g. history, science, math).
2. The application loads a form specific to the selected quiz category. This form contains a list of questions and multiple choice answers.
3. The user selects their answer and clicks a "submit" button.
4. The application shows the user whether their answer is correct or incorrect.
5. The application moves on to the next question and repeats steps 3-4 until all questions in the quiz are answered.
6. At the end of the quiz, the application displays the user's score and gives them the option to retake the quiz or go back to the main menu.

To incorporate the topics you've already covered, you can use the menu toolstrip for the main menu and create separate forms for each quiz category as child forms. You can also use labels and buttons to display questions and answer choices, and change their properties (like the background color of a label) based on whether the answer is correct or incorrect.

Let me know if you have any questions or need help with the code!
can you provide me with the codes for this ? i like this already
 
can you provide me with the codes for this ? i like this already
Certainly! Here's an example code for the quiz application using multiple forms:

Main menu form:

C#:
public partial class MainMenuForm : Form
{
    public MainMenuForm()
    {
        InitializeComponent();
    }

    private void historyToolStripMenuItem_Click(object sender, EventArgs e)
    {
        HistoryQuizForm historyQuizForm = new HistoryQuizForm();
        historyQuizForm.ShowDialog();
    }

    private void scienceToolStripMenuItem_Click(object sender, EventArgs e)
    {
        ScienceQuizForm scienceQuizForm = new ScienceQuizForm();
        scienceQuizForm.ShowDialog();
    }

    private void mathToolStripMenuItem_Click(object sender, EventArgs e)
    {
        MathQuizForm mathQuizForm = new MathQuizForm();
        mathQuizForm.ShowDialog();
    }
}

History quiz form:

C#:
public partial class HistoryQuizForm : Form
{
    private int currentQuestion = 0;
    private int score = 0;

    private List<Question> questions = new List<Question>()
    {
        new Question("When did World War II end?", new List<string>() {"1945", "1939", "1941", "1943"}, "1945"),
        new Question("Who was the first president of the United States?", new List<string>() {"Thomas Jefferson", "George Washington", "John Adams", "Abraham Lincoln"}, "George Washington"),
        new Question("What year was the United Nations founded?", new List<string>() {"1935", "1945", "1947", "1950"}, "1945")
    };

    public HistoryQuizForm()
    {
        InitializeComponent();
        DisplayQuestion();
    }

    private void DisplayQuestion()
    {
        Question question = questions[currentQuestion];
        questionLabel.Text = question.Text;
        answerAButton.Text = question.Answers[0];
        answerBButton.Text = question.Answers[1];
        answerCButton.Text = question.Answers[2];
        answerDButton.Text = question.Answers[3];
    }

    private void CheckAnswer(string selectedAnswer)
    {
        Question question = questions[currentQuestion];
        if (question.CorrectAnswer == selectedAnswer)
        {
            score++;
            feedbackLabel.Text = "Correct!";
            feedbackLabel.ForeColor = Color.Green;
        }
        else
        {
            feedbackLabel.Text = "Incorrect!";
            feedbackLabel.ForeColor = Color.Red;
        }

        // Disable answer buttons
        answerAButton.Enabled = false;
        answerBButton.Enabled = false;
        answerCButton.Enabled = false;
        answerDButton.Enabled = false;

        // Show next button
        nextButton.Visible = true;
    }

    private void answerAButton_Click(object sender, EventArgs e)
    {
        CheckAnswer(answerAButton.Text);
    }

    private void answerBButton_Click(object sender, EventArgs e)
    {
        CheckAnswer(answerBButton.Text);
    }

    private void answerCButton_Click(object sender, EventArgs e)
    {
        CheckAnswer(answerCButton.Text);
    }

    private void answerDButton_Click(object sender, EventArgs e)
    {
        CheckAnswer(answerDButton.Text);
    }

    private void nextButton_Click(object sender, EventArgs e)
    {
        currentQuestion++;

        if (currentQuestion == questions.Count)
        {
            // Quiz is over
            MessageBox.Show($"Quiz complete! You scored {score}/{questions.Count}.");
            this.Close();
        }
        else
        {
            // Load next question
            DisplayQuestion();
            feedbackLabel.Text = "";
            feedbackLabel.ForeColor = Color.Black;

            // Enable answer buttons
            answerAButton.Enabled = true;
            answerBButton.Enabled = true;
            answerCButton.Enabled = true;
            answerDButton.Enabled = true;

            // Hide next button
            nextButton.Visible = false;
        }
    }
}

Science quiz form and Math quiz form can follow a similar structure, but with different questions and answers.

I hope this helps! Let me know if you have any questions or need further assistance.
 
Back
Top