Having text inside NumericUpDown control, after the number

前端 未结 4 2022
自闭症患者
自闭症患者 2020-12-09 04:39

Is it possible in WinForms to show a text inside a NumericUpDown control? For example I want to show the value in my numericupdown control is micro ampers so it should be li

4条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-09 05:20

    Here's what I used for showing at least 2 digits for a hexadecimal NumericUpDown that are prefixed by 0x. It puts text in the control and avoids using "debounce" by using the .Net provided field ChangingText

        class HexNumericUpDown2Digits : NumericUpDown
        {
            protected override void UpdateEditText()
            {
                if (Hexadecimal)
                {
                    ChangingText = true;
                    Text = $"0x{(int)Value:X2}";
                }
                else
                {
                    base.UpdateEditText();
                }
            }
        }
    

提交回复
热议问题