0

I am working on a Customized Main Menu for a game (COD MW2) so I need to know how when somebody clicks on an item (`labe or textbox) it will call another form that will contain some custom parameters, without making a form for each Label/textbox !

It's kinda like the Properties Window in Visual Studio! When I select a label you choose the parameters and stuff.
If you didn't understood what I mean please tell me :)

I've already tried to do this but I failed :/

EDIT:

I just found how to do it but i still don't know how to send the info back to the Form1 and Reload The Form1 .... help me please :))

5
  • 1
    You might want to give a more exact example (including specific buttons/labels/text boxes) for you Visual Studio example. It's not very clear as-is what behavior you want to copy from the "Properties Window" Commented Nov 17, 2015 at 14:51
  • can you show your code how you tried to solve this? Commented Nov 17, 2015 at 14:53
  • well , i didnt started my project yet , but this is the idea : when somebody Clicks on a Label OR a textbox , the Form2 will show with some parameters , like when i click on a label1 the Form2 will popup with label1's text in a textbox and i can change it ... u got it ? Commented Nov 17, 2015 at 15:06
  • 1
    "I've already tried to do this but I failed" then you say "I didn't start my project yet" so which is it? Commented Nov 17, 2015 at 15:20
  • i tried some codes from other guys ... i didnt did anythin yet , because this is the heart of the project .. i need this to start it :) Commented Nov 17, 2015 at 15:30

1 Answer 1

2

EDIT: Open Forms With Parameters

Form1:

private void label1_Click(object sender, EventArgs e)
        {
            Form2 f2 = new Form2(label1);
            f2.Show();
            f2.textBox1.Text = label1.Text;
        }

Form2:

public partial class Form2 : Form
    {
        Label x;
        public Form2(Label y)
        {
            InitializeComponent();
            x = y;
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {
            x.Text = textBox1.Text;
        }
    }
Sign up to request clarification or add additional context in comments.

3 Comments

can u check my Comment up there ? i just explained it more i think :/
Respect ! Thats Just What i was needing ! but i need to add more things ! thank you :)
Hey , and how Can i send the Info Back to The Form1 and edit The text in Form1 to the Value that user typed in Form2 ? ty

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.