Hi, I am trying to create a form application with console. I label my text box using, this.Test = "Assignment 8". There is a button saying press me. When button is pressed, the box that comes up needs to say Click me in the title area. I can't find anything on what the proper line of code would be.

Thank you.

Teddi

I think, what I can make up out of your question is:
Set the Text property of your TextBox in the Click event handler of your "Press me" button.

Sorry, I wasn't clear. I can get the 'Assignment 8' to show up in the original form by typing: this.Text = "Assignment 8"; But when the 'Press Me' button is pressed, a new box opens up with a label saying 'The button has been clicked'. In the title area, (the same spot as the original box that said Assignment 8), I need it to say 'Click Me'. I tried to put this.Text = "Click Me" in the method for the click button. It changed the title in the ORIGINAL box, not the new one. The new one has nothing in that space.

Attachments Assignment8_2.PNG 10.61 KB assignment_8_1.PNG 21.03 KB

Here is the code I have. I guess I am not sure how to add it to the event handler properly. I have tried a few different things, but not getting the results I need.

Thanks.

// Set the btnClickMe text to "Press Me" and the btnExit text to "Exit".
            this.btnClickMe.Text = "Press me";
            this.btnExit.Text = "Exit";

            // Add the two button controls to the form.
            this.Controls.AddRange(new Control[] { btnClickMe, btnExit });

            // Set the btnClickMe location to coordinates 15, 20 
            this.btnClickMe.Location = new System.Drawing.Point(15, 20);
            // Register a new EventHandler for the Click event of the btnClickMe button 
            this.btnClickMe.Click += new EventHandler(this.btnClickMe_Click);
            // "Click Me" in the MessageBox title bar when the Click event is fired.
            this.Text = "Click me";
            // ...and the btnExit location to coordinates 15, 60.
            this.btnExit.Location = new System.Drawing.Point(15, 60);
            // ..new EventHandler for the Click event of the btnExit button.
            this.btnExit.Click += new EventHandler(btnExit_Click);

I am not able to understand your question .... you want to set text of which control???? and where you want to add the code please can you clarify your problem?

OK, in the screen shots, do you see where the first one says Assignment 8? After clicking the Press Me button, the next box pops up. On the second box, where Assignment 8 is in the first box, needs to say Click Me. But nothing is there. I don't thing that would be a 'control'. It is more the 'title' of the box. I just can't find any information on how to label that area with a click event.

Use this call to open your message box:

MessageBox.Show("testmessage", "My message in title", MessageBoxButtons.OK);

what is box??? is it the form you created??? or panel what is it? if it is form then you can simply write

this.Text="Click me";

and if the box is a messageBox then add this code

MessageBox.Show("message" , "Title", MessageBoxButtons.OK, MessageBoxIcon.Information);
private void button1_Click(object sender, EventArgs e)
        {
            Form form = new Form();
            Label lbl = new Label();
            form.Controls.Add(lbl);
            lbl.Location = textBox1.Location;
            form.Size = this.Size;
            lbl.Text = textBox1.Text;
            form.ShowDialog();
        }
This question has already been answered. Start a new discussion instead.