c# – How do I make this textbox into this search’s context


basically I tried to make a spawned textbox work in another private void. Right now it’s just showing me “The name ‘userinput’ does not exist in current context”. Btw it’s inside a mousedown event.

    private void mousedownevent(object sender, MouseEventArgs e)
    {
       TextBox userinput = new TextBox();
        userinput.Location = new Point(224, 239);
        userinput.Name = "placeholder";
    }

    private void search_Click(object sender, EventArgs e)
        {
          if (userinput.text == "placeholder")
        {
            MessageBox.Show("placeholdeer");
        }
        }

tried using
var search = this.controls[“placeholder”]

also tried making them public.

Leave a Reply

Your email address will not be published. Required fields are marked *