English 中文(简体)
• 如何在装货时将无效价值确定在日期。
原标题:How to set null value to Datetimepicker when load?
  • 时间:2014-04-15 12:16:24
  •  标签:
  • vb.net

I have a Datetimepicker1, i want to set it to empty when load, and show value after chose. I have found a code

        Datetimepicker1.Format = DateTimePickerFormat.Custom
        Datetimepicker1.CustomFormat = " " 

但它在选择后没有显示价值。

问题回答

引言

日期? 页: 1

由于日期可能无效,但可以确定日期。 MinValue, 它是未启用日期的违约值。 那么,如果是 d,你就要检查。 价值 = 日期。 MinValue,如果是,将它视为无效。

然而,如果你想要在没有选定价值时真正加以区别,最容易的方式是确定日期。 彩虹 方框是真实的,然后是检查。 检查,如果正确的话,你读取价值,否则就认为价值无效。

您:

DateTime? myselectedDate = null;

private void DateTimePicker1_ValueChanged(Object sender, EventArgs e) {

   myselectedDate = DateTimePicker1.Value;

}

而且

this.dateTimePicker1.Format = DateTimePickerFormat.Custom;
this.dateTimePicker1.CustomFormat = " "; //a string with one whitespace

日期 皮克尔无价值。 数值或缺省值: 日期:MinValue 。 你的法典修改了格式,以便无所作为。

为再次显示日期,只是改动了<代码>DatetimePicker.Format。 必要时再次:

DateTimePicker1.Format = DateTimePickerFormat.Long;

由于你安排了您的时日制片人,你应在日制片人的价值变化活动中写以下代码;

日期:picker1.Format = 日期PickerFormat.short(您需要简短的类型等)





相关问题
Is Shared ReadOnly lazyloaded?

I was wondering when I write Shared ReadOnly Variable As DataType = New DataType() Or alternatively Shared ReadOnly Variable As New DataType() Is it lazy loaded or as the instance initializes? ...

Entertaining a baby with VB.NET

I would like to write a little application in VB.NET that will detect a baby s cry. How would I get started with such an application?

Choose Enter Rather than Pressing Ok button

I have many fields in the page and the last field is a dropdown with list of values. When I select an item in a dropdown and press Enter, it doesn t do the "Ok". Instead I have to manually click on Ok ...

ALT Key Shortcuts Hidden

I am using VS2008 and creating forms. By default, the underscore of the character in a textbox when using an ampersand is not shown when I run the application. ex. "&Goto Here" is not ...

Set Select command in code

On button Click I want to Set the Select command of a Gridview. I do this and then databind the grid but it doesn t work. What am i doing wrong? protected void bttnView_Click(object sender, ...

Hover tooltip on specific words in rich text box?

I m trying to create something like a tooltip suddenly hoovering over the mouse pointer when specific words in the richt text box is hovered over. How can this be done?

热门标签