如何从DateTimePicker更改时间 [英] how to change the time from DateTimePicker

查看:118
本文介绍了如何从DateTimePicker更改时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好所有



我正试图从晚上到第二天早上改变时间



当时间调整为12:00:00 AM日期自动增加

当我退后11:30:00:PM自动减少天数

特别是当上午12:30:00增加并返回12:00:00时

数字继续上涨



 公开  Form2 
公开 Sub ()

' Windows窗体设计器需要此调用。
InitializeComponent()
.Size = 大小( 408 ,< span class =code-digit > 328 )
Dim DateTimePicker1 作为 DateTimePicker()
DateTimePicker1.Location = 点( 10 30
DateTimePicker1.Size = 大小( 140 32

Dim DateTimePicker2 < span class =code-keyword> As New DateTimePicker()
DateTimePicker2.Location = 点( 190 30
DateTimePicker2.Size = 大小( 100 32
DateTimePicker2.Format = DateTim ePickerFormat.Time
DateTimePicker2.ShowUpDown = True
AddHandler DateTimePicker2.ValueChanged,< span class =code-keyword> AddressOf DateTimePicker2_ValueChanged

Me .Controls.Add(DateTimePicker1)
< span class =code-keyword> Me .Controls.Add(DateTimePicker2)

' 在InitializeComponent()调用后添加任何初始化。

结束 Sub

私有 Sub Form2_Load( ByVal 发​​件人作为系统。对象 ByVal e As System.Event Args)句柄 MyBase .Load

结束 Sub

私有 Sub DateTimePicker2_ValueChanged( ByVal sender As System。 Object ByVal e As System.EventArgs)
'
结束 < span class =code-keyword> Sub
结束



http://s28.postimg.org/s7ofw82gd/ change_value_datetimepicker.png [ ^ ]



任何感兴趣的代码

请得到帮助

非常感谢

解决方案

该问题与 DateTimePicker无关这只是用来挑选一些时间。通常,在系统上任意设置日期/时间是个坏主意。您无法提供合理的准确性等。 (我可以用来欺骗复制保护系统,但更新的保护不受这些技巧的影响。:-))



解决方案可以在这里找到:如何在.net中设置全局日期时间 [ ^ ]。



请注意,您必须使用P / Invoke,这会损害您的代码的平台兼容性。



- SA

hello all

I'm trying to change the time
today from the evening to the next morning
when time is adjusted to 12:00:00 AM dates automatically increase
when I step back 11:30:00: PM is automatically reduced the number of days
particularly when there is increased 12:30:00 AM and return 12:00:00 AM
the numbers continue to rise day

Public Class Form2
    Public Sub New()

        ' This call is required by the Windows Form Designer.
        InitializeComponent()
        Me.Size = New Size(408, 328)
        Dim DateTimePicker1 As New DateTimePicker()
        DateTimePicker1.Location = New Point(10, 30)
        DateTimePicker1.Size = New Size(140, 32)

        Dim DateTimePicker2 As New DateTimePicker()
        DateTimePicker2.Location = New Point(190, 30)
        DateTimePicker2.Size = New Size(100, 32)
        DateTimePicker2.Format = DateTimePickerFormat.Time
        DateTimePicker2.ShowUpDown = True
        AddHandler DateTimePicker2.ValueChanged, AddressOf DateTimePicker2_ValueChanged

        Me.Controls.Add(DateTimePicker1)
        Me.Controls.Add(DateTimePicker2)

        ' Add any initialization after the InitializeComponent() call.

    End Sub
  
    Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub

    Private Sub DateTimePicker2_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
        '?
    End Sub
End Class


http://s28.postimg.org/s7ofw82gd/change_value_datetimepicker.png[^]

any code that is appreciated
please get help
thanks a lot

解决方案

The question has nothing to do with DateTimePicker which is only used to pick some time. Generally, it's a bad idea to arbitrary set date/time on the system. You cannot provide reasonable accuracy, and so on. (I can be used to cheat copy protection systems, but newer protection is immune to such tricks. :-))

The solution can be found here: How to set global DateTime in .net[^].

Note that you have to use P/Invoke which compromises the platform compatibility of your code.

—SA


这篇关于如何从DateTimePicker更改时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆