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 7183603
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T18:01:01+00:00 2026-05-28T18:01:01+00:00

I have created a custom message box with a textbox for input which appears

  • 0

I have created a custom message box with a textbox for input which appears under a certain condition in form1. I want form1 to hold the value of the textbox if the submit btn is clicked. I am not getting the desired result.

This is similar to this however I don’t want the processing to happen in the message box because the process requires so many variables that I would have to transfer to the messsagebox.

Form condition

}
else //NOT ALL APPROVE
{
     string BtnClicked = DenyEmpRequest.ShowBox(AllDenied, EmpRequestID); 

     if (BtnClicked == "1") //SUBMIT BTN WAS CLICKED
     {
         DenyEmpRequest emp = new DenyEmpRequest();
         string reason = emp.Reason_Txt.Text;
     }

I know that it is because I am creating a new instance of the form that I used in the messagebox when I said “DenyEmpRequest emp = new DenyEmpRequest();”. I don’t know any other way to access the textbox in the messagebox.

Messagebox code

    public static string ShowBox(string DenyEmp, string RequestID)
    {
        newMessageBox = new DenyEmpRequest();
        newMessageBox.EmpToDeny_lbl.Text = DenyEmp;
        EmpRequestID = RequestID;
        newMessageBox.ShowDialog(); 
        return Button_id;
    }

    private void SubmitBtn_Click(object sender, EventArgs e)
    {
        if (Reason_Txt.Text == string.Empty)
        {
            NoReason_Lbl.Visible = true;
        }
        else
        {
            Button_id = "1";
            newMessageBox.Dispose();
        }
  • 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-05-28T18:01:01+00:00Added an answer on May 28, 2026 at 6:01 pm

    Looks like you’re overcomplicating it. If you are just trying to retrieve a string from a custom MessageBox, just make a form with an OK/Cancel button and a text box. Make a public string property that wraps around the value of the text box’s “Text” property. And make the form set it’s DialogResult to DialogResult.OK if the OK button is clicked, DialogResult.Cancel if the cancel button is clicked.

    Then you can call this form with code shown below:

    using (CustomMessageBox myMessageBox = new CustomMessageBox())
    {
        myMessageBox.Text = "Initial text"; // optionally set the initial value of the text box
        if (myMessageBox.ShowDialog(this) == DialogResult.OK)
        {
            someVariable = myMessageBox.Text;
        }
    }
    

    This is the format you should be using.

    EDIT:
    In reference to your comment, if you have a form with a text box on it, just write the property like this:

    public class CustomMessageBox : Form
    {
        public string Text
        {
            get
            {
                return textBox.Text;
            }
            set
            {
                textBox.Text = value;
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a custom dialog box which requires 3 fields public class Test{
I have created a custom TextBox control which also contains a RequiredFieldValidator. Everything works
If have created a custom role within SqlServer which I added to the db__denydatareader
I have created a custom ItemsControl called Toolbox. I want to be able to
I have added a form to a project to create a custom message box.
I have created custom MembershipUser, MembershipProvider and RolePrivoder classes. These all work and I
friends, i have created custom title bar using following titlebar.xml file with code <?xml
I have created a custom dialog for Visual Studio Setup Project using the steps
I have created a custom TitleWindow whcih i use as a popup. The contents
I have created a custom list as a feature in sharepoint. i need to

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.