using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace V9.__DateTimePicker_控件_1_
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
//datetimepicker
//显示时间
//默认显示日期,显示时间必须将 ShowUpDown属性设置为 True, 将Format属性设置为 True ;
//自定义日期 先将 Format 属性设置为Custom,然后将 CustomFormat 属性设置为一个 格式字符串
//Year 返回年
//Month 返回月
//Date 返回日期部分
//Day 返回日
//DayOfWeek 返回星期
//Hour 返回小时
//Mintue 返回分钟
//Second 返回秒
//TimeOfDay 返回当前时间
//Millsecond 返回毫秒
//天干 0甲、 1乙 、2丙 、3丁 、4戊 、5已、 6庚、 7辛、 8壬、 9葵
//地支 0子、1丑、2寅、3卯、4辰、5巳、6午、7未、8申、9酉、10戌、11亥
//天干=(年份-4)%10 地支 (年份-4)%12
}
private void dateTimePicker3_ValueChanged(object sender, EventArgs e)
{
string tg = "甲乙丙丁戊已庚辛壬葵";
string dz = "子丑寅卯辰巳午未申酉戌亥";
string sx = "鼠牛虎兔龙蛇马羊猴鸡狗猪";
int year = dateTimePicker3.Value.Year;
label1.Text = "您选择的年为农历:" + tg[(year - 4) % 10] + dz[(year - 4) % 12] + "年,是" + sx[(year - 4) % 12];
}
}
}
联系客服