C# 自定义控件,日期时间选择输入插件
权声明:本文为博主原创文章,未经博主允许不得转载。
- // 为textBox1添加一个日期时间选择控件
- DateTimeChoser.AddTo(textBox1);
DateTimeChoser.Designer.cs
- using System;
- using System.ComponentModel;
- using System.Drawing;
- using System.Reflection;
- using System.Windows.Forms;
- namespace pictureAnalyse
- {
- /// <summary>
- /// 此类用于实现一个日期时间辅助输入插件,调用逻辑:
- /// new DateTimeChoser(textBox1); //即可为textBox1绑定一个日期时间输入控件
- /// </summary>
- public partial class DateTimeChoser : UserControl
- {
- public static bool showConfirmButton = true; // 日期时间选择时,是否显示确定按钮
- /// <summary>
- /// 为textBoox添加一个日期时间选择控件,辅助日期时间的输入
- /// </summary>
- public static void AddTo(TextBox textBox)
- {
- try
- {
- DateTime time = DateTime.Parse(textBox.Text);
- }
- catch (Exception ex)
- {
- textBox.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
- }
- textBox.MouseClick += textBoox_MouseClick;
- }
- /// <summary>
- /// 为textBoox添加一个日期时间选择控件,辅助日期时间的输入,并设置初始时显示的时间
- /// </summary>
- public static void AddTo(TextBox textBoox, DateTime dateTime)
- {
- textBoox.Text = dateTime.ToString("yyyy-MM-dd HH:mm:ss");
- textBoox.MouseClick += textBoox_MouseClick;
- }
- private static void textBoox_MouseClick(object sender, MouseEventArgs e)
- {
- TextBox textBox = sender as TextBox;
- // 创建一个关联到textBox的日期时间选择控件
- DateTimeChoser choser = new DateTimeChoser();
- choser.showOn(textBox);
- // 设置显示的时间为文本框中的日期时间
- try
- {
- DateTime time = DateTime.Parse(textBox.Text);
- choser.setDateTime(time);
- }
- catch (Exception ex) { }
- }
- public DateTimeChoser()
- {
- InitializeComponent();
- init();
- }
- private void init()
- {
- // 时分秒设置
- for (int i = 0; i < 24; i++) comboBox_hour.Items.Add((i < 10 ? "0" : "") + i);
- for (int i = 0; i < 60; i = i + 1) comboBox_minite.Items.Add((i < 10 ? "0" : "") + i);
- for (int i = 0; i < 60; i++) comboBox_second.Items.Add((i < 10 ? "0" : "") + i);
- comboBox_hour.DropDownStyle = ComboBoxStyle.DropDownList;
- comboBox_minite.DropDownStyle = ComboBoxStyle.DropDownList;
- comboBox_second.DropDownStyle = ComboBoxStyle.DropDownList;
- //设置显示的日期时间
- setDateTime(DateTime.Now);
- }
- public delegate void DateTimeChanged_Handle(object sender, EventArgs e);
- [Description("当选择日期或时间变动时,调用此事件"), Category("自定义事件")]
- public event DateTimeChanged_Handle DateTimeChanged;
- // 选择日期变动
- private void monthCalendar1_DateSelected(object sender, DateRangeEventArgs e)
- {
- DateTime S = monthCalendar1.SelectionStart;
- string date = S.ToString("yyyy-MM-dd");
- if (!date.Equals(label_date.Text))
- {
- label_date.Text = date;
- if (DateTimeChanged != null) DateTimeChanged(this, new EventArgs());
- }
- }
- //选择的时间变动
- private void TimeChanged(object sender, EventArgs e)
- {
- string time = comboBox_hour.Text + ":" + comboBox_minite.Text + ":" + comboBox_second.Text;
- if (!time.Equals(label_time.Text))
- {
- label_time.Text = time;
- if (DateTimeChanged != null) DateTimeChanged(this, new EventArgs());
- }
- }
- // 设置显示到指定的日期时间
- public void setDateTime(DateTime now)
- {
- // 初始时界面显示当前的日期时间
- label_date.Text = now.ToString("yyyy-MM-dd");
- monthCalendar1.SetDate(now);
- // 设置时间
- label_time.Text = now.ToString("HH:mm:ss");
- comboBox_hour.SelectedIndex = now.Hour;
- comboBox_minite.SelectedIndex = now.Minute;
- comboBox_second.SelectedIndex = now.Second;
- }
- // 获取当前选择的日期时间
- public string getDateTime()
- {
- return label_date.Text + " " + label_time.Text;
- }
- # region 自定义控件输入绑定逻辑,将当前日期时间控件绑定到指定的TextBox
- private Form form;
- TextBox textbox;
- private Delegate[] textboxEvents;
- // 在指定的TextBox中,显示当前日期时间选择控件,进行日期时间的输入
- public void showOn(TextBox textBox, int offX = 0, int offY = 0)
- {
- Point P = getLocation(textBox);
- P = new Point(P.X, P.Y + textBox.Height);
- show(textBox, P.X + offX, P.Y + offY, showConfirmButton);
- }
- // 在TextBox点击时,调用DateTimeChoser进行日期时间的选择,当再次点击时,关闭之前的日期选择状态
- private void show(TextBox textbox, int L, int T, bool showButton)
- {
- this.textbox = textbox;
- textboxEvents = getEvents(textbox, "MouseClick"); // 获取TextBox原有事件处理逻辑
- ClearEvent(textbox, "MouseClick"); // 移除TextBox原有MouseClick事件处理逻辑
- // 新建一个窗体
- form = new Form();
- form.Width = this.Width;
- form.Height = this.Height;
- if (showButton) form.Height = this.Height + 40;
- form.FormBorderStyle = FormBorderStyle.None; // 无边框
- form.ShowInTaskbar = false; // 不在任务栏中显示
- form.BackColor = Color.White; //
- form.Location = new Point(L, T);
- // 将当前日期时间选择控件添加到form中
- this.Left = 0; this.Top = 0;
- form.Controls.Add(this);
- if (showButton)
- {
- Button button = new Button();
- button.Text = "确定";
- button.ForeColor = Color.Blue;
- button.Left = (this.Width - button.Width) / 2;
- button.Top = this.Height + (40 - button.Height) / 2;
- form.Controls.Add(button);
- button.Click += button_Click;
- }
- form.Show(); // 显示日期时间选择
- form.Location = new Point(L, T);
- form.TopMost = true;
- form.Activate(); // 当前界面获取到焦点
- Form Parent = getParentForm(textbox); // 获取TextBox的父窗体
- if (Parent != null) Parent.FormClosed += Parent_FormClosed;
- textbox.MouseClick += textbox_MouseClick;
- }
- // 添加
- private void button_Click(object sender, EventArgs e)
- {
- textbox_MouseClick(textbox, null);
- }
- // 关闭当前form
- private void Parent_FormClosed(object sender, FormClosedEventArgs e)
- {
- if (form != null)
- {
- form.Close();
- form = null;
- }
- }
- private void textbox_MouseClick(object sender, MouseEventArgs e)
- {
- TextBox textBox = sender as TextBox;
- textBox.Text = getDateTime();
- if (form != null)
- {
- form.Close();
- form = null;
- }
- textBox.MouseClick -= textbox_MouseClick; // 移除当前事件处理逻辑
- addEvents(textBox, "MouseClick", textboxEvents); // 还原TextBox原有事件处理逻辑
- }
- # endregion
- // 获取给定控件的父窗体
- public static Form getParentForm(Control control)
- {
- if (control is Form) return control as Form;
- Control C = control;
- while (C.Parent != null)
- {
- if (C.Parent is Form) return C.Parent as Form;
- else C = C.Parent;
- }
- return null;
- }
- #region 获取控件的坐标信息
- /// <summary>
- /// 获取任意控件相对于屏幕的坐标
- /// </summary>
- public static Point getLocation(Control control)
- {
- Point P;
- if (control is Form) P = getFormClientLocation(control as Form);
- else P = control.Location;
- if (control.Parent != null)
- {
- Control parent = control.Parent;
- Point P2 = getLocation(parent);
- P = new Point(P.X + P2.X, P.Y + P2.Y);
- }
- return P;
- }
- /// <summary>
- /// 获取Form窗体有效显示区域的起点,相对于屏幕的坐标
- /// </summary>
- public static Point getFormClientLocation(Form form)
- {
- Rectangle rect = form.ClientRectangle;
- int offx = 0, offy = 0;
- if (form.FormBorderStyle != FormBorderStyle.None)
- {
- offx = (form.Width - rect.Width) / 2;
- offy = (form.Height - rect.Height) - 8;
- }
- Point P = new Point(form.Location.X + offx, form.Location.Y + offy);
- return P;
- }
- # endregion
- # region 动态修改控件对应的事件处理逻辑
- // ClearEvent(button1,"Click");//就会清除button1对象的Click事件的所有挂接事件。
- private void ClearEvent(Control control, string eventname)
- {
- if (control == null) return;
- if (string.IsNullOrEmpty(eventname)) return;
- BindingFlags mPropertyFlags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic;
- BindingFlags mFieldFlags = BindingFlags.Static | BindingFlags.NonPublic;
- Type controlType = typeof(System.Windows.Forms.Control);
- PropertyInfo propertyInfo = controlType.GetProperty("Events", mPropertyFlags);
- EventHandlerList eventHandlerList = (EventHandlerList)propertyInfo.GetValue(control, null);
- FieldInfo fieldInfo = (typeof(Control)).GetField("Event" + eventname, mFieldFlags);
- Delegate d = eventHandlerList[fieldInfo.GetValue(control)];
- if (d == null) return;
- EventInfo eventInfo = controlType.GetEvent(eventname);
- foreach (Delegate dx in d.GetInvocationList())
- eventInfo.RemoveEventHandler(control, dx);
- }
- // getEvent(button1,"Click"); //就会获取到button1对象的Click事件的所有挂接事件。
- private Delegate[] getEvents(Control control, string eventname)
- {
- if (control == null) return null;
- if (string.IsNullOrEmpty(eventname)) return null;
- BindingFlags mPropertyFlags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic;
- BindingFlags mFieldFlags = BindingFlags.Static | BindingFlags.NonPublic;
- Type controlType = typeof(System.Windows.Forms.Control);
- PropertyInfo propertyInfo = controlType.GetProperty("Events", mPropertyFlags);
- EventHandlerList eventHandlerList = (EventHandlerList)propertyInfo.GetValue(control, null);
- FieldInfo fieldInfo = (typeof(Control)).GetField("Event" + eventname, mFieldFlags);
- Delegate d = eventHandlerList[fieldInfo.GetValue(control)];
- if (d == null) return null;
- Delegate[] events = new Delegate[d.GetInvocationList().Length];
- int i = 0;
- foreach (Delegate dx in d.GetInvocationList()) events[i++] = dx;
- return events;
- }
- // addEvents(button1,"Click"); // 为button1对象的Click事件挂接事件
- private void addEvents(Control control, string eventname, Delegate[] evenets)
- {
- if (control == null) return;
- if (string.IsNullOrEmpty(eventname)) return;
- Type controlType = typeof(System.Windows.Forms.Control);
- EventInfo eventInfo = controlType.GetEvent(eventname);
- foreach (Delegate e in evenets)
- eventInfo.AddEventHandler(control, e);
- }
- # endregion
- }
- }
DateTimeChoser.cs
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Drawing;
- using System.Data;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace pictureAnalyse
- {
- partial class DateTimeChoser
- {
- /// <summary>
- /// 必需的设计器变量。
- /// </summary>
- private System.ComponentModel.IContainer components = null;
- /// <summary>
- /// 清理所有正在使用的资源。
- /// </summary>
- /// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
- protected override void Dispose(bool disposing)
- {
- if (disposing && (components != null))
- {
- components.Dispose();
- }
- base.Dispose(disposing);
- }
- #region 组件设计器生成的代码
- /// <summary>
- /// 设计器支持所需的方法 - 不要
- /// 使用代码编辑器修改此方法的内容。
- /// </summary>
- private void InitializeComponent()
- {
- this.monthCalendar1 = new System.Windows.Forms.MonthCalendar();
- this.panel_consume = new System.Windows.Forms.Panel();
- this.label6 = new System.Windows.Forms.Label();
- this.comboBox_second = new System.Windows.Forms.ComboBox();
- this.label5 = new System.Windows.Forms.Label();
- this.comboBox_minite = new System.Windows.Forms.ComboBox();
- this.label4 = new System.Windows.Forms.Label();
- this.comboBox_hour = new System.Windows.Forms.ComboBox();
- this.panel1 = new System.Windows.Forms.Panel();
- this.label_date = new System.Windows.Forms.Label();
- this.label_time = new System.Windows.Forms.Label();
- this.panel2 = new System.Windows.Forms.Panel();
- this.panel_consume.SuspendLayout();
- this.panel1.SuspendLayout();
- this.panel2.SuspendLayout();
- this.SuspendLayout();
- //
- // monthCalendar1
- //
- this.monthCalendar1.AllowDrop = true;
- this.monthCalendar1.Location = new System.Drawing.Point(-3, 15);
- this.monthCalendar1.Name = "monthCalendar1";
- this.monthCalendar1.TabIndex = 0;
- this.monthCalendar1.DateSelected += new System.Windows.Forms.DateRangeEventHandler(this.monthCalendar1_DateSelected);
- //
- // panel_consume
- //
- this.panel_consume.BackColor = System.Drawing.Color.White;
- this.panel_consume.Controls.Add(this.label6);
- this.panel_consume.Controls.Add(this.comboBox_second);
- this.panel_consume.Controls.Add(this.label5);
- this.panel_consume.Controls.Add(this.comboBox_minite);
- this.panel_consume.Controls.Add(this.label4);
- this.panel_consume.Controls.Add(this.comboBox_hour);
- this.panel_consume.Location = new System.Drawing.Point(-2, 173);
- this.panel_consume.Name = "panel_consume";
- this.panel_consume.Size = new System.Drawing.Size(222, 30);
- this.panel_consume.TabIndex = 23;
- //
- // label6
- //
- this.label6.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
- this.label6.AutoSize = true;
- this.label6.Location = new System.Drawing.Point(195, 10);
- this.label6.Name = "label6";
- this.label6.Size = new System.Drawing.Size(17, 12);
- this.label6.TabIndex = 15;
- this.label6.Text = "秒";
- //
- // comboBox_second
- //
- this.comboBox_second.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
- this.comboBox_second.FormattingEnabled = true;
- this.comboBox_second.Location = new System.Drawing.Point(149, 6);
- this.comboBox_second.Name = "comboBox_second";
- this.comboBox_second.Size = new System.Drawing.Size(40, 20);
- this.comboBox_second.TabIndex = 14;
- this.comboBox_second.Text = "0";
- this.comboBox_second.SelectedIndexChanged += new System.EventHandler(this.TimeChanged);
- //
- // label5
- //
- this.label5.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
- this.label5.AutoSize = true;
- this.label5.Location = new System.Drawing.Point(126, 10);
- this.label5.Name = "label5";
- this.label5.Size = new System.Drawing.Size(17, 12);
- this.label5.TabIndex = 13;
- this.label5.Text = "分";
- //
- // comboBox_minite
- //
- this.comboBox_minite.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
- this.comboBox_minite.FormattingEnabled = true;
- this.comboBox_minite.Location = new System.Drawing.Point(80, 6);
- this.comboBox_minite.Name = "comboBox_minite";
- this.comboBox_minite.Size = new System.Drawing.Size(40, 20);
- this.comboBox_minite.TabIndex = 12;
- this.comboBox_minite.Text = "0";
- this.comboBox_minite.SelectedIndexChanged += new System.EventHandler(this.TimeChanged);
- //
- // label4
- //
- this.label4.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
- this.label4.AutoSize = true;
- this.label4.Location = new System.Drawing.Point(57, 10);
- this.label4.Name = "label4";
- this.label4.Size = new System.Drawing.Size(17, 12);
- this.label4.TabIndex = 11;
- this.label4.Text = "时";
- //
- // comboBox_hour
- //
- this.comboBox_hour.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
- this.comboBox_hour.FormattingEnabled = true;
- this.comboBox_hour.Location = new System.Drawing.Point(9, 6);
- this.comboBox_hour.Name = "comboBox_hour";
- this.comboBox_hour.Size = new System.Drawing.Size(42, 20);
- this.comboBox_hour.TabIndex = 10;
- this.comboBox_hour.Text = "0";
- this.comboBox_hour.SelectedIndexChanged += new System.EventHandler(this.TimeChanged);
- //
- // panel1
- //
- this.panel1.BackColor = System.Drawing.Color.White;
- this.panel1.Controls.Add(this.label_date);
- this.panel1.Controls.Add(this.label_time);
- this.panel1.Location = new System.Drawing.Point(-3, -1);
- this.panel1.Name = "panel1";
- this.panel1.Size = new System.Drawing.Size(223, 23);
- this.panel1.TabIndex = 25;
- //
- // label_date
- //
- this.label_date.AutoSize = true;
- this.label_date.BackColor = System.Drawing.Color.White;
- this.label_date.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
- this.label_date.Location = new System.Drawing.Point(18, 3);
- this.label_date.Name = "label_date";
- this.label_date.Size = new System.Drawing.Size(98, 16);
- this.label_date.TabIndex = 26;
- this.label_date.Text = "2016-06-12";
- //
- // label_time
- //
- this.label_time.AutoSize = true;
- this.label_time.BackColor = System.Drawing.Color.White;
- this.label_time.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
- this.label_time.Location = new System.Drawing.Point(118, 3);
- this.label_time.Name = "label_time";
- this.label_time.Size = new System.Drawing.Size(80, 16);
- this.label_time.TabIndex = 25;
- this.label_time.Text = "12:23:35";
- //
- // panel2
- //
- this.panel2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
- this.panel2.Controls.Add(this.panel1);
- this.panel2.Controls.Add(this.panel_consume);
- this.panel2.Controls.Add(this.monthCalendar1);
- this.panel2.Location = new System.Drawing.Point(0, 0);
- this.panel2.Name = "panel2";
- this.panel2.Size = new System.Drawing.Size(215, 202);
- this.panel2.TabIndex = 26;
- //
- // DateTimeChoser
- //
- this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.Controls.Add(this.panel2);
- this.Name = "DateTimeChoser";
- this.Size = new System.Drawing.Size(215, 202);
- this.panel_consume.ResumeLayout(false);
- this.panel_consume.PerformLayout();
- this.panel1.ResumeLayout(false);
- this.panel1.PerformLayout();
- this.panel2.ResumeLayout(false);
- this.ResumeLayout(false);
- }
- #endregion
- private System.Windows.Forms.MonthCalendar monthCalendar1;
- private System.Windows.Forms.Panel panel_consume;
- private System.Windows.Forms.Label label6;
- private System.Windows.Forms.ComboBox comboBox_second;
- private System.Windows.Forms.Label label5;
- private System.Windows.Forms.ComboBox comboBox_minite;
- private System.Windows.Forms.Label label4;
- private System.Windows.Forms.ComboBox comboBox_hour;
- private System.Windows.Forms.Panel panel1;
- private System.Windows.Forms.Label label_date;
- private System.Windows.Forms.Label label_time;
- private System.Windows.Forms.Panel panel2;
- }
- }
添加以上两个类到项目,编译运行一次。自定义的DateTimeChoser控件会出现在工具箱中。
可直接拖拽至Form窗体中使用,也可通过代码进行调用。
C# 自定义控件,日期时间选择输入插件的更多相关文章
- Java+Selenium操作日期时间选择框插件
在自动化测试的时候我们经常会碰到下面的时间日期插件(这个时候这个文本框是不运行我们输入时间的), 我们可以用java获取当前日期,然后用Selenium结合JS代码就可以直接往文本框输入内容. 像这种 ...
- jquery插件课程1 幻灯片、城市选择、日期时间选择、拖放、方向拖动插件
jquery插件课程1 幻灯片.城市选择.日期时间选择.拖放.方向拖动插件 一.总结 一句话总结:都是jquery插件,都还比较小,参数(配置参数.数据)一般都是通过json传递. 1.插件配置数据 ...
- Jquery mobiscroll 移动设备(手机)wap日期时间选择插件以及滑动、滚动插件
Jquery Mobiscroll是一个用于触摸设备(Android phones, iPhone, iPad, Galaxy Tab)的日期和时间选择器jQuery插件.以及各种滑动插件 可以让用户 ...
- 24款最好的jQuery日期时间选择器插件
如果你正在创建一个网络表单,有很多事情你需要在你的应用程序中使用.有时您需要特别的输入,从用户的日期和时间,如发票日期,生日,交货时间,或任何其他此类信息.如果你有这样的需要,可以极大地从动态的jQu ...
- flatpickr功能强大的日期时间选择器插件
flatpickr日期时间选择器支持移动手机,提供多种内置的主题效果,并且提供对中文的支持.它的特点还有: 使用SVG作为界面的图标. 兼容jQuery. 支持对各种日期格式的解析. 轻量级,高性能, ...
- 日期时间范围选择插件:daterangepicker使用总结
分享说明: 项目中要使用日期时间范围选择对数据进行筛选;精确到年月日 时分秒;起初,使用了layui的时间日期选择插件;但是在IIE8第一次点击会报设置格式错误;研究了很久没解决,但能确定不是layu ...
- 日期时间选择器插件flatpickr
前言:在网页上需要输入时间的时候,我们可以用HTML5的inputl中的date类型.但是如下入所示,有些浏览器不支持.flatpickr这个小插件可以解决这个问题. 1.flatpickr日期时间选 ...
- 15. Fluentd输入插件:in_tail用法详解
in_tail输入插件内置于Fluentd中,无需安装. 它允许fluentd从文本文件尾部读取日志事件,其行为类似linux的tail -F命令(按文件名来tail). 这几乎是最常用的一个输入插件 ...
- 9月23日JavaScript作业----日期时间选择
作业二:日期时间选择 <div style="width:600px; height:100px;"> <select id="year"&g ...
随机推荐
- GIT 如何从另一分支合并特定的文件
是否遇到过这种情景: 您在一个分支上工作,发现该分支上的某些文件实现的功能已经在其他分支上实现了 但因为这两个分支实现不同的功能,因此不能进行简单的合并工作,但您又不想重复其他已经完成的工作 以下操作 ...
- 转: MinGw离线安装方法集合
转自: http://www.cnblogs.com/smartdog/archive/2012/03/30/2425124.html https://www.zhihu.com/question/2 ...
- Google声明机器学习在自己定制的芯片比方普通的GPU和CPU快15到30倍
GOOGLE开发自己的加速机器学习的芯片已经不是什么秘密了,最先发布出来的是TPU(Tensor Processing Units),在2016年5月I/O开发大会上发布的.可是没有发布相关的细节情况 ...
- USACO Arithmetic Progressions(暴力)
题目请点我 题解: 这道题的题意是找出集合里全部固定长度为N的等差数列.集合内的元素均为P^2+q^2的形式(0<=p,q<=M).时间要求5s内.本着KISS,直接暴力. 可是后来竟超时 ...
- FireDAC中的SQLite(二)
我们接下来将要使用FDDemo.sdb数据库进行访问,开始我们的第一个SQLite访问例子. 我们的FDDemo.sdb存放目录在:C:\Program Files (x86)\Embarcadero ...
- MySQL开启慢查询日志时报Errcode: 13 的解决方法
开启慢查询日志时会出现(Errcode: 13 - Permission denied)文件找不到的错误,但文件明明是存在的并且有读写的权限. mysql> set global slow_qu ...
- Vim的行号、语法显示等设置(.vimrc文件的配置)以及乱码解决
在终端下使用vim进行编辑时,默认情况下,编辑的界面上是没有显示行号.语法高亮度显示.智能缩进 等功能的.为了更好的在vim下进行工作,需要手动设置一个配置文件:.vimrc.在启动vim时,当前用户 ...
- Android学习之Android studio TraceView和lint工具的使用具体解释
上次讲述了一下Android studio Terminal的使用配置,今天又学习了一下关于Traceview和lint工具的使用. 首先来讲lint吧: Android lint工具是Android ...
- C# 动态解析表达式
需求 我们很难捉摸用户的思维,即使使用非常正式的文档规范某些数据的定义.结果的标准等,也不能抵挡住用户不断变化的需求,但他们有个万变不离的东西——你做这个东西要是万能的,即输入参数类型.个数等发生改变 ...
- MDX Step by Step 读书笔记(九) - Working with Time 处理时间
开篇介绍 这一章节主要用到的 MDX 函数: PeriodsToDate( [Level , [Member]] ) - 从指定级别的范围内,返回与指定成员同一级别,从第一个期间开始到指定成员结束的期 ...