C# How to send the value of the numericUpDown to the textbox in Hexadecimal?

Asked

Viewed 222 times

3

then... the numericUpDown even has the count format in Hexadecimal, but when sending to texBox it counts only in decimal has some form of textbox to receive the Numeric given value in Hexadecimal?

I send the Numeric value to the textbox so:

    private void numericUpDown1_ValueChanged(object sender, EventArgs e)
    {
        textBox1.Text = Convert.ToString(numericUpDown1.Value);
    }

1 answer

3


Just do a parse for whole and call the method ToString with formatting X2 for two hexadecimal digits.

textBox1.Text = ((int)numericUpDown1.Value).ToString("X2");
  • Poxa worth myth, came out perfect!

  • Tiago, I got a problem, I was both sending the value of Numeric to the textbox and the textbox to Numeric, as a form of Load, when opening the file they synchronize and the úsuario can adjust the value of the textbox manually by Numeric, can you do the same process? or this time I’ll have to give up that timing?

  • numericUpDown1.Value =int. Parse(textBox1.Text, System.Globalization.Numberstyles.Hexnumber)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.