Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Sounds like you're calling the formatting in the wrong place. You probably want to call that <code>textbox1.Text = int_Value.ToString("N", nFI);</code> when your value is changing in addition to when you click the checkbox (ie, whenever you click on your calculator buttons or on <code>textboxt1.TextChanged</code> or whatever), and only if your checkbox is checked (<code>if (checkbox1.Checked == true) textbox1.Text...</code>). It should also probably be in a separate function, that's called in all the places it's needed.</p> <p><strong>Edit for clarity</strong></p> <p>The problem you're likely having is that you have multiple sources that are changing the display in <code>textbox1</code>. The code you posted is most likely in some <code>checkbox_CheckChanged(sender, e)</code> event handler.</p> <p>You likely also have code elsewhere (maybe calculator buttons or something) that will change the value in your textbox (something like...</p> <pre><code>double value = Convert.ToDouble(textbox.Text); value = value + 1; textbox1.Text = value.ToString(); </code></pre> <p>in a +1 button, for example?)</p> <p>What you want to do is have a separate <code>displayValue(double value)</code> function that will format it correctly all the time, maybe something like...</p> <pre><code>private void SetDisplayValue(double value) { NumberFormatInfo nFI = new CultureInfo("en-US", false).NumberFormat if (checkBox.Checked == true) textbox1.Text = value.ToString("N", nFI); else textbox1.Text = value.ToString(); } </code></pre> <p>and every place that you would have set textbox1.Text in your code, regardless of whether it's in a button or a _CheckChanged or whatnot, instead call that private function.</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.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      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