Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7813779
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T04:58:53+00:00 2026-06-02T04:58:53+00:00

I’m trying to make a relatively basic text based RPG in C# in Visual

  • 0

I’m trying to make a relatively basic text based RPG in C# in Visual Studio. An I’ve gotten hung up trying to have a method in a class react to a button click on a form. Like to move from one method to another based on the button clicked.

Let me give you a basic layout of the program.

I have a frmMain and a cls_EVENTS. It’ll get more complex, but that’s for a time once I actually get stuff working.

I want the frmMain to be where the player interacts with the program. It has the text screen, buttons, status meters, most of the good fun stuff. Below the text screen are 6 buttons (labeled btn1 – btn6, respectively) that I plan on changing the text to, to reflect the available actions of the current scene/events (inspect that, go right, tell that guy that you and his mother had dinner last night).

the controls to ‘make’ the main menu are in cls_EVENTS, mostly to make it more convenient for a Main Menu button to just simply call it to get the player back to the main menu (rather then just copy-pasting the code from the frmMain method).

public partial class frmMain : Form
{
    //creates a static copy of the form that references to this form, I believe.
    public static frmMain MainForm { get; private set; }

    public frmMain()
    {
        InitializeComponent();

        // sets the static form as a copy of this form named MainForm.
        frmMain.MainForm = this;

        // calls the MainMenu() method in the cls_EVENTS class.
        cls_EVENTS.MainMenu();
    }

public void btn1_Click(object sender, EventArgs e)
{
}

//Same thing all the way down to btn6_Click
//And a couple of functions for manipulating the controls on the form... 
//(enabling buttons, pushing text to the textbox, etc)

My cls_EVENTS is where I want to actually code the events. Like the MainMenu event that’ll change the text in the textbox, change the text on the button to reflect the current options, and disable the buttons I won’t need.

public class cls_EVENTS
{
    /*the Main menu, solely here for 'conveinence' (so I can have a Main Menu button on my form)*/
    public static void MainMenu()
    {
        //clears the text screen
        frmMain.MainForm.ScreenTextClear();

        //Enables the first button, disables the rest.
        frmMain.MainForm.ButtonEnable(true, false, false, false, false, false);

        //indent = true, write text to screen.
        frmMain.MainForm.ScreenText(true, "Welcome to the alpha of this game.");

        //test to make sure it ADDS TO the text rather then overwriting.
        frmMain.MainForm.ScreenText(true, "Hi");

        //changes the six button texts to the following six strings
        frmMain.MainForm.ButtonText("New Game", "Load Game", "About", "---", "---", "---");  

        //problem area

        //when player clicks button one
        //start the NewGame() method

        //when player clicks button two, after I eventually code such a function.
        //start the LoadGame() function

        //etc.     
    }

    Public void NewGame()
    {
        //etc.
    }
}

I’ve tried using a loop with a Sleep method in it to check a variable that each button would add a different number to (as long as intSelected was 0, the loop would continue, btn1 would add 1, etc., etc.)

But that caused the program to hang.

Plus, I feel that it would be a messy, unprofessional way of doing what I want to do. And while I may not be a professional, even I have standards.

Does anyone know of a way to pause the programs execution until a button is pressed? or have a better idea on how to get done what I want to get done? I can’t just simply code the functions into the click events, as what these buttons do would be constantly changing.

I will go ahead and say that C# is not a language I am strong in. I was originally doing this in VB.Net, but ran into the same problem, and was lead to believe that C# was a bit more flexible. The only C-language I’m even vaguely familiar with is C++, and my class in that was a least a year-and-a-half ago. So, please forgive ‘stupid’ coding, as I am a little rusty.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T04:58:54+00:00Added an answer on June 2, 2026 at 4:58 am

    After some more experimenting and more Google searching, I think I may have found it.

    public static void MainMenu()
    {
        frmMain.MainForm.ScreenTextClear();
    
        frmMain.MainForm.ButtonEnable(true, false, false, false, false, false);
        frmMain.MainForm.ScreenText(true, "Welcome to the alpha of this game.");
        frmMain.MainForm.ScreenText(true, "Hi");
        frmMain.MainForm.ButtonText("New Game", "Load Game", "About", "---", "---", "---");  
    
        // Potential solution.
        frmMain.MainForm.btn1.Click += delegate(object sender, EventArgs e)
            {
                NewGame();
            };    
    }
    

    This seems to be doing what I want to get done. The text loads up, the buttons activate, then clicking on them starts up the appropriate method. Rise-repeat.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a text area in my form which accepts all possible characters from
I have a reasonable size flat file database of text documents mostly saved in
I am trying to loop through a bunch of documents I have to put
I have a bunch of posts stored in text files formatted in yaml/textile (from
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.