C# numericUpDownを16進数表記に変更する

  • 作成日 2021.08.24
  • 更新日 2022.04.11
  • C#
C# numericUpDownを16進数表記に変更する

C#で、Hexadecimalを使用して、numericUpDownnumericUpDownを16進数表記に変更するサンプルコードを記述してます。

環境

  • OS windows10 pro 64bit
  • Microsoft Visual Studio Community 2019 Version 16.7.1

Hexadecimal使い方

Hexadecimalを使用することで、numericUpDownを16進数表記に変更することが可能です。

numericUpDown1.Hexadecimal = True / False;

サンプルコード

以下は、
「実行」ボタンをクリックすると、16進数表記に変更する
サンプルコードとなります。

using System;
using System.Windows.Forms;

namespace FormTestApp
{
    public partial class Form1 : Form
    {

        public Form1()
        {
            InitializeComponent();

        }

        private void button1_Click(object sender, EventArgs e)
        {
            bool flg = true;
            numericUpDown1.Hexadecimal = flg;
        }
    }
}

16進数表記に設定されたことが確認できます。