带有if语句的datetime列表框 [英] listbox with datetime with if statement
本文介绍了带有if语句的datetime列表框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我如何使用if语句与listbox + datetimepicker
ex :
listbox1.Items.add(datetimepicker1.value);
IF声明
if(DateTime.Now ==(列表框中的时间))
{
Go();
}
how i can use if statement with listbox + datetimepicker
ex :
listbox1.Items.add(datetimepicker1.value);
IF statement
if (DateTime.Now == ( time in listbox ))
{
Go();
}
推荐答案
我不会:DateTime精确到毫秒,因此,您下拉列表中的任何特定日期时间值只会与DateTime.Now匹配百万分之一秒 - 所以您甚至抓住正确的一天的可能性非常小。
如果您想找到合适的日子,您可以:
I wouldn't: a DateTime is accurate to milliseconds, and so any specific DateTime value from your drop down will only match DateTime.Now for one millionth of a second - so the chances of you even "catching the right day" are seriously minimal.
If you are trying to find just the right day, you can:
if (DateTime.Now.Date == ((DateTime) myListBox.SelectedItem).Date)
{
但是对于任何更准确的东西它会变得更复杂,因为没有特定属性this小时或这一分钟
SelectedValue改为SelectedItem:O [/ edit]
But for anything more accurate it gets more complex, as there is no specific property for "this hour" or "this minute"
[edit]SelectedValue changed to SelectedItem :O [/edit]
这篇关于带有if语句的datetime列表框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文