RAG
RAG

Reputation: 17

Is there a way to have a textbox value show up in another textbox when a button is clicked?

I have implemented a trackbar that adjusts a textbox value accordingly with the slider as shown with the code below.

private void trackBar_Temp_Scroll(object sender, EventArgs e)
        {
            Oven_Temp.Text = trackBar_Temp.Value.ToString();

I am trying to have the value displayed in the oven_temp textbox appear within another textbox called feedback, when a button is clicked using this code.

private void Oven_select_Click(object sender, EventArgs e)
        {
            Oven_Temp.Text = Feeback.Text;

No errors seem to be appearing however no output appears within the feedback textbox.

Anyone able to help a student out for a coursework who has done a limited amount of coding before? :)

Upvotes: 0

Views: 431

Answers (1)

Christopher
Christopher

Reputation: 9804

You set Oven_Temp.Text to the value of Feeback.Text. According to your text, you however wanted to set Feeback.Text to the value of Oven_Temp.Text. So you got the Assignment flipped.

Try Feeback.Text = Oven_Temp.Text;

The other common mistake is that the Event is not actually registered with the Button. You can put a simple Message Box in to test if the event even fires. That is usually one of the first things I check with Events.

Upvotes: 1

Related Questions