c#DateTimePicker验证设置未选择或未选中的值

时间:2016-02-15 02:01:12

标签: c# datetimepicker

如何将datetimepicker值声明为null?这是我的代码。

user@nano:~/luaTest/thirdparty/libircclient-1.8$ export LDFLAGS="-ldl -L/usr/local/ssl/lib -lssl -lcrypto"
user@nano:~/luaTest/thirdparty/libircclient-1.8$ export CPATH=/usr/local/includeuser@nano:~/luaTest/thirdparty/libircclient-1.8$ export LIBRARY_PATH=/usr/local/lib
user@nano:~/luaTest/thirdparty/libircclient-1.8$ export LD_LIBRARY_PATH=/usr/local/lib
user@nano:~/luaTest/thirdparty/libircclient-1.8$ ./configure --enable-openssl --enable-ipv6
checking for g++... g++
checking whether the C++ compiler works... yes
checking for C++ compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking for gcc... gcc
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for ar... ar
checking for ranlib... ranlib
checking how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for stdbool.h that conforms to C99... yes
checking for _Bool... yes
checking for an ANSI C-conforming const... yes
checking for size_t... yes
checking whether time.h and sys/time.h may both be included... yes
checking for stdlib.h... (cached) yes
checking for GNU libc compatible malloc... yes
checking sys/select.h usability... yes
checking sys/select.h presence... yes
checking for sys/select.h... yes
checking sys/socket.h usability... yes
checking sys/socket.h presence... yes
checking for sys/socket.h... yes
checking types of arguments for select... int,fd_set *,struct timeval *
checking whether lstat correctly handles trailing slash... yes
checking whether stat accepts an empty string... no
checking for localtime_r... yes
checking for socket... yes
checking for socket in -lsocket... no
checking for getaddrinfo... yes
checking for inet_pton... yes
checking for getaddrinfo in -lnsl... yes
checking For MinGW32... no
checking for CRYPTO_new_ex_data in -lcrypto... no
configure: error: OpenSSL not found
user@nano:~/luaTest/thirdparty/libircclient-1.8$ make
for subdir in src examples; do \
        make -C $subdir || exit 1; \
    done
make[1]: Entering directory `/home/user/luaTest/thirdparty/libircclient-1.8/src'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/home/user/luaTest/thirdparty/libircclient-1.8/src'
make[1]: Entering directory `/home/user/luaTest/thirdparty/libircclient-1.8/examples'
gcc -o spammer spammer.o -L../src/ -lircclient -lpthread -lssl -lcrypto  -lnsl
/usr/local/lib/../lib/libcrypto.a(dso_dlfcn.o): In function `dlfcn_globallookup':
dso_dlfcn.c:(.text+0x15): undefined reference to `dlopen'
dso_dlfcn.c:(.text+0x2b): undefined reference to `dlsym'
dso_dlfcn.c:(.text+0x35): undefined reference to `dlclose'
/usr/local/lib/../lib/libcrypto.a(dso_dlfcn.o): In function `dlfcn_bind_func':
dso_dlfcn.c:(.text+0x33b): undefined reference to `dlsym'
dso_dlfcn.c:(.text+0x410): undefined reference to `dlerror'
/usr/local/lib/../lib/libcrypto.a(dso_dlfcn.o): In function `dlfcn_bind_var':
dso_dlfcn.c:(.text+0x48b): undefined reference to `dlsym'
dso_dlfcn.c:(.text+0x566): undefined reference to `dlerror'
/usr/local/lib/../lib/libcrypto.a(dso_dlfcn.o): In function `dlfcn_load':
dso_dlfcn.c:(.text+0x5e0): undefined reference to `dlopen'
dso_dlfcn.c:(.text+0x658): undefined reference to `dlclose'
dso_dlfcn.c:(.text+0x69d): undefined reference to `dlerror'
/usr/local/lib/../lib/libcrypto.a(dso_dlfcn.o): In function `dlfcn_pathbyaddr':
dso_dlfcn.c:(.text+0x736): undefined reference to `dladdr'
dso_dlfcn.c:(.text+0x821): undefined reference to `dlerror'
/usr/local/lib/../lib/libcrypto.a(dso_dlfcn.o): In function `dlfcn_unload':
dso_dlfcn.c:(.text+0x87e): undefined reference to `dlclose'
collect2: error: ld returned 1 exit status
make[1]: *** [spammer] Error 1
make[1]: Leaving directory `/home/user/luaTest/thirdparty/libircclient-1.8/examples'
make: *** [all] Error 1
user@nano:~/luaTest/thirdparty/libircclient-1.8$ 
你可以编辑我的代码吗?因为它是不可挽回的。

3 个答案:

答案 0 :(得分:0)

您无法在那里设置null值。 DateTimePicker.Value不可为空,其最低值为1/1/1753 00:00:00

如果您要分配null只是为了检查它是否已初始化。您可以检查MinDate属性的值。

了解更多here

答案 1 :(得分:0)

由于DateTimePicker.Value属性的数据类型为DateTime,因此仅检查年份是否大于1900将仅提供有效日期。如果您的应用程序需要,您可以将年份值更改为更新的值,但1900之后的任何内容通常都被视为有效日期。

dateTimePicker.Value.Year > 1900

答案 2 :(得分:0)

/ * 下面是我在C#中为Windows窗体的DateTime Picker选择日期时编写的用于验证到期ID ID的方法。通过demonguru18 aka techhowdy.com * /

private bool isIDExpired()
        {
            DateTime objDateTime = DateTime.Parse(dtpIDExpiry.Value.ToString());
            DateTime today = DateTime.Today;
            int day = objDateTime.Day - today.Day;
            int month = objDateTime.Month - today.Month;
            int year = objDateTime.Year - today.Year;
            if (day == 0 && month == 0 && year == 0)
            {
                MessageBox.Show("Your ID is Expiring Today. Please Provide new ID Expiry Date.");
                return false;
            }
            else if (year < 0)
            {
                MessageBox.Show("Your ID has already Expired. Please Provide valid ID Expiry Date.");
                return false;
            }
            else if (month < 0 &&  year < 0)
            {
                MessageBox.Show("Your ID has already Expired. Please Provide valid ID Expiry Date.");
                return false;
            }

            else if (month == 0 && day < 0 && year == 0)
            {
                MessageBox.Show("Your ID has already Expired. Please Provide valid ID Expiry Date.");
                return false;
            }

            return true;
        }`