Note that there are some explanatory texts on larger screens.

plurals
  1. POUse Form Constructor repeatedly to refresh the label text
    primarykey
    data
    text
    <p>I'm <strong>newbie</strong> for C# and i have a little project. I'm stucked somewhere. I explained it here (with sample source codes) :</p> <p>I have a form application. I'm asking users select an option from 2 buttons. There are 2 buttons (YES and NO) . My codes like this :</p> <pre><code>public partial class Form1 : Form { public int choice=0; public Form1() { if(choice == 0) { label.Text = "Please push one of these buttons :"; // And there are buttons below this label } else if(choice == 1) { label.Text = "You just pushed YES button"; } else if(choice == 2) { label.Text = "You just pushed NO button"; } } private void buttonYes_Click(object sender, EventArgs e) { choice = 1; /* I have to use one of these here for redraw whole form this.Refresh(); this.Invalidate(); */ } private void buttonNo_Click(object sender, EventArgs e) { choice = 2; /* I have to use one of these here for redraw whole form this.Refresh(); this.Invalidate(); */ } } </code></pre> <p>As you see, when user click one of YES or NO button, whole constructor function should be re-executed. And label should be "You just pushed YES / NO button".</p> <p>But when i use this.Refresh() , nothing happening when i clik buttons. Still label is "Please push one of these buttons :" .</p> <p>When i use this.Invalidate() , all buttons disappering, and label is still "Please push one of these buttons :" . </p> <p>What should i do ?</p> <p>Thanks.</p> <p><strong>PS</strong> I've found <a href="https://stackoverflow.com/questions/7347714/how-to-refresh-or-flush-the-c-sharp-windows-form">this question</a> BEFORE ask this one. But as you see, accepted answer not working for me.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload