numericUpDown 为什么不能赋值C#

numericUpDown 为什么不能赋值C#,第1张

Form的构造方法一定要先执行了InitializeComponent();方法后才会构造出你拖上去的控件,是不是你把赋值语句放在InitializeComponent();前面了,或者重写了构造方法,没加InitializeComponent();?

另外给这个控件赋值就用thisnumericUpDown1Value = 10;就可以

不能这样赋值的。

不过datetimepicker控件是满足你的要求的。首先在属性里面讲formart属性设置为short,然后将showupdown属性设置为true即可变成numericupdown样式了。

怎么会呢?用下面简单代码验证,证明确实是当前值!

Private Sub NumericUpDown1_ValueChanged(sender As SystemObject, e As SystemEventArgs) Handles NumericUpDown1ValueChanged

Label1Text = NumericUpDown1Value

End Sub

numericUpDown1Value = 0;//初始值,输入框的默认值

numericUpDown1DecimalPlaces = 0;//显示小数点位数,0不显示小数点及小数

numericUpDown1Value = 0;//初始值,输入框的默认值

numericUpDown1Increment = 1;//增长

numericUpDown1InterceptArrowkeys = true;//上下键增长

// numericUpDown2、numericUpDown3上同

numericUpDown1Maxium = 23;//最多

numericUpDown1Minium = 0;//最小值

numericUpDown2Maxium = 59;//最多值

numericUpDown2Minium = 0;//最小值

numericUpDown3Maxium = 59;//最多值

numericUpDown3Minium = 0;//最小值

DateTime _date = new DateTime(DateTimeNowYear,DateTimeNowMonth,DateTimeNowDay,numericUpDown1Value,numericUpDown2Value,numericUpDown3Value);

string time = _dateToString("HH:mm:ss");

或者

string time = numericUpDown1valueToString();

time += ":"+numericUpDown2valueToString();

time += ":"+numericUpDown3valueToString();

//如:23:59:59

Private Sub NumericUpDown1_ValueChanged(sender As Object, e As EventArgs) Handles NumericUpDown1ValueChanged

Dim tp(NumericUpDown1Value - 1) As TabPage

TabControl1TabPagesClear()

For i As Integer = 0 To tpLength - 1

tp(i) = New TabPage

tp(i)Text = "新表格 " & i + 1

Next

TabControl1TabPagesAddRange(tp)

End Sub

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBaseLoad

TabControl1TabPagesClear()

End Sub

//Apple是整数个,没必要用double

int totalApple = 100;

int displayApple;

private void numPie_ValueChanged(object sender, EventArgs e)

{

displayApple = totalApple - CalcRemainApple();//所有的numeric事件都这样写

}

private int CalcRemainApple()

{

//代表那个东西需要消耗的apple数量

return totalApple - numPieValue10 - numCiderValue - numCrispValue - numSause;

}

以上就是关于numericUpDown 为什么不能赋值C#全部的内容,包括:numericUpDown 为什么不能赋值C#、给numericupdown怎样赋一个datetime型的值,只要年月日、VB中用NumericUpDown控件的valueChanged事件,得到的值是上一个值非当前值,怎么设置等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址:https://www.54852.com/web/9525444.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-04-29
下一篇2023-04-29

发表评论

登录后才能评论

评论列表(0条)

    保存