c#实现日历_GUI
展示
主要代码
public partial class calendar : Form{public calendar(){InitializeComponent();}int year, month;private void textBoxMonth_TextChanged(object sender, EventArgs e){if (textBoxMonth.Text == "")month = 0;month = Convert.ToInt32(textBoxMonth.Text);}private void buttonSearch_Click(object sender, EventArgs e){seach();}private void textBoxYear_TextChanged(object sender, EventArgs e){year = Convert.ToInt32(textBoxYear.Text);}private void buttonLastMonth_Click(object sender, EventArgs e){int year = Convert.ToInt32(textBoxYear.Text);int month=Convert.ToInt32(textBoxMonth.Text);if (year == 1 && month == 1){year = 1;month = 1;}else{if (month > 1){month--;textBoxMonth.Text = Convert.ToString(month);seach();}else{textBoxMonth.Text = Convert.ToString(12);year--;textBoxYear.Text = Convert.ToString(year);seach();}}}private void buttonNextMonth_Click(object sender, EventArgs e){int month = Convert.ToInt32(textBoxMonth.Text);if (month < 12){month++;textBoxMonth.Text = Convert.ToString(month);seach();}else{textBoxMonth.Text = Convert.ToString(1);int year = Convert.ToInt32(textBoxYear.Text);year++;textBoxYear.Text = Convert.ToString(year);seach();}}private void buttonLastYear_Click(object sender, EventArgs e){int year = Convert.ToInt32(textBoxYear.Text);if(year>1){year--;textBoxYear.Text = Convert.ToString(year);textBoxMonth.Text = Convert.ToString(1);seach();}}private void buttonNextYear_Click(object sender, EventArgs e){int year = Convert.ToInt32(textBoxYear.Text);year++;textBoxYear.Text = Convert.ToString(year);textBoxMonth.Text = Convert.ToString(1);seach();}public void seach(){if (textBoxYear.Text == "" || textBoxMonth.Text == "")labelAlert.Text = "请输入年份及月份";elseif (Convert.ToInt32(textBoxYear.Text) <= 0 || Convert.ToInt32(textBoxMonth.Text) <= 0 || Convert.ToInt32(textBoxMonth.Text) > 12)labelAlert.Text = "输入的年份与月份不能小于0,月份不能大于12";else{textBoxDemonstrate.Text = "周一 周二 周三 周四 周五 周六 周日" + "\r\n" + "\r\n" + "\r\n";textBoxDemonstrate.Text += compute(year, month);}}public bool leap_Year(int year){if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0))return true;elsereturn false;}public string compute(int year, int month){int days1 = (year - 1) * 365;for (int i = 1; i < year; i++){if (leap_Year(i))days1++;}int[] monthArray = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };if (leap_Year(year))monthArray[1] = 29;int days2 = 0, monthDays = monthArray[month - 1];for (int i = 0; i < month - 1; i++){days2 += monthArray[i];}int days = days1 + days2;string strCalendar="";for (int i = 0; i < days % 7; i++)strCalendar += " ";for(int i=1;i<monthDays+1;i++){if (i < 10)strCalendar += " " + i + " ";elsestrCalendar += Convert.ToString(i + " ");if ((i+ days % 7) % 7 == 0)strCalendar += "\r\n"+"\r\n" + "\r\n";}return strCalendar;}}
c#实现日历_GUI相关推荐
- app如何打开了request url_手机日历app内如何打开节日提醒功能?支持提前提醒节日的云便签...
我们一年中要度过的节日有很多,除了法定节假日之外,还有其他的很多节日,例如西方传来的圣诞节.万圣节,国际性的节日例如父亲节.母亲节等,还有一些传统节日例如小寒.冬至.腊八等,这些都是不放假的. 有时候 ...
- Python Qt GUI设计:QCalendar日历类和QDateTimeEdit时间类(基础篇—20)
目录 1.QCalendar日历类 2.QDateTimeEdit时间类 1.QCalendar日历类 QCalendar是一个日历控件,它提供了一个基于月份的视图,允许用户通过鼠标或键盘选择日期,默 ...
- mui ios中form表单中点击输入框头部导航栏被推起及ios中form表单中同时存在日期选择及输入框时,日历选择页面错乱bug...
一.ios header导航栏被推起解决方法 1 设置弹出软键盘时自动改变webview的高度 plus.webview.currentWebview().setStyle({ softinputMo ...
- 【Qt】qss样式表之:QCalendarWidget,日历窗口样式表设置
1.效果图: 2.qss样式表 其中表头的背景颜色等设置不起作用,只好在下面的代码中实现. /*日历*/ QCalendarWidget QHeaderView {qproperty-minimumS ...
- 年季度月周日控件html,基于bootstrap按年、季度、年月、年月日的日历插件(原创)...
插件描述:基于bootstrap按年.季度.年月.年月日的日历插件,作为bootstrapdatetimepicker的扩展 更新时间:2020-07-02 22:02:19 更新说明:修改yk-da ...
- Java项目:日历万年历(java+swing)
源码获取:博客首页 "资源" 里下载! 功能简介: 万年历 启动类: public class CalendarMainClass { public static void mai ...
- python中ttk和tkinter_Python tkinter与ttk日历
我正在使用 this代码在我的Tkinter上创建一个简单的日历.当我在主根窗口上放置日历时,日历显示正常.因此,我决定放置另一个按钮,它将创建一个Tkinter顶层窗口并在顶层窗口上放置另外一个日历 ...
- iOS访问系统日历 添加提醒事件
1 添加隐私请求提示 Privacy - Calendars Usage Description 2 代码 #import <EventKit/EventKit.h> // 添加提醒事件 ...
- 【iOS】日历行程的增删改查(完整)
前言 我们可以使用系统提供的EventKit框架来访问和操作用户的日历日程和提醒(虽然日历和提醒是两个独立的app,但是是用同一个框架来处理数据).同样地,日历和提醒的数据的数据,都是存储在同一个叫做 ...
最新文章
- java 语言实现的随机数生成算法
- SQL应用与开发:(三)数据操作 #183; 改 AND 删
- ubuntun安装ssh,并远程链接服务器操作
- TDengine安装
- 华硕z170a如何开启m2_「科技犬」新品游戏本、翻转屏评测汇总:华硕微星荣耀戴尔,选谁...
- 摩根士丹利 Morgan Stanley 2008校园招聘已经正式开
- BZOJ1468: Tree BZOJ3365: [Usaco2004 Feb]Distance Statistics 路程统计
- Mail_Android_Video_SW_DDK_Intergration_Guide_And_Codec_User_Manual中文翻译【chapter1】
- 海康8700视频调用
- Charles 手机https抓包
- iPhone开发入门(一)
- SCCM 2016安装部署
- 火车头采集翻页内容_火车头采集器怎么采集内容页的分页
- 我数星星...宝宝,你智商差点,就数月亮吧
- 安全管家安卓_安卓手机自带的管家好,还是另外获取的管家好呢?这4点你要知道...
- cshtml中文乱码
- Camera2 打开相机预览界面
- 程序员1个经验反复用了10年?工资不涨,那是最终被迫成长的结果
- 第六讲 双指针、BFS与图论、单链表
- 小米智能摄像机云台Pro如何插入视频监控存储卡