定时提醒窗体??? 首先应该用定时器,system.times.timer你可以做一个窗体,将其隐藏,然后定时器定时去查当前时间是否和要求的时间一样,然后可以弹出窗口,为了好控制,你可以做系统托盘 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 colin666(边缘)讲的对 http://www.codeproject.com/有实例,楼主可以参考一下。 呵呵,都说了。不过注意有两个timer,选择有图形的那个。 这个东东我做过,以下是完整的源代码:using System;using System.Drawing;using System.Collections;using System.ComponentModel;using System.Windows.Forms;using System.Data;namespace NoticePad{ /// <summary> /// 定时提醒的小工具。 /// </summary> public class Form1 : System.Windows.Forms.Form { private System.Windows.Forms.Label label1; private System.Windows.Forms.Label label2; private System.Windows.Forms.TextBox textBox1; private System.Windows.Forms.Timer timer1; private System.Windows.Forms.NumericUpDown ndHour; private System.Windows.Forms.NumericUpDown ndMinute; private System.Windows.Forms.Button btn_OK; private System.ComponentModel.IContainer components; public Form1() { // // Windows 窗体设计器支持所必需的 // InitializeComponent(); // // TODO: 在 InitializeComponent 调用后添加任何构造函数代码 // } /// <summary> /// 清理所有正在使用的资源。 /// </summary> protected override void Dispose( bool disposing ) { if( disposing ) { if (components != null) { components.Dispose(); } } base.Dispose( disposing ); } #region Windows Form Designer generated code /// <summary> /// 设计器支持所需的方法 - 不要使用代码编辑器修改 /// 此方法的内容。 /// </summary> private void InitializeComponent() { this.components = new System.ComponentModel.Container(); this.ndHour = new System.Windows.Forms.NumericUpDown(); this.ndMinute = new System.Windows.Forms.NumericUpDown(); this.label1 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label(); this.textBox1 = new System.Windows.Forms.TextBox(); this.btn_OK = new System.Windows.Forms.Button(); this.timer1 = new System.Windows.Forms.Timer(this.components); ((System.ComponentModel.ISupportInitialize)(this.ndHour)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.ndMinute)).BeginInit(); this.SuspendLayout(); // // ndHour // this.ndHour.Location = new System.Drawing.Point(8, 8); this.ndHour.Maximum = new System.Decimal(new int[] { 23, 0, 0, 0}); this.ndHour.Name = "ndHour"; this.ndHour.Size = new System.Drawing.Size(48, 25); this.ndHour.TabIndex = 0; // // ndMinute // this.ndMinute.Location = new System.Drawing.Point(112, 8); this.ndMinute.Maximum = new System.Decimal(new int[] { 59, 0, 0, 0}); this.ndMinute.Name = "ndMinute"; this.ndMinute.Size = new System.Drawing.Size(48, 25); this.ndMinute.TabIndex = 1; // // label1 // this.label1.AutoSize = true; this.label1.Location = new System.Drawing.Point(64, 16); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(21, 18); this.label1.TabIndex = 2; this.label1.Text = "时"; // // label2 // this.label2.AutoSize = true; this.label2.Location = new System.Drawing.Point(176, 16); this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(21, 18); this.label2.TabIndex = 3; this.label2.Text = "分"; // // textBox1 // this.textBox1.Location = new System.Drawing.Point(8, 40); this.textBox1.Multiline = true; this.textBox1.Name = "textBox1"; this.textBox1.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; this.textBox1.Size = new System.Drawing.Size(368, 200); this.textBox1.TabIndex = 4; this.textBox1.Text = "写入提醒的内容......"; // // btn_OK // this.btn_OK.Location = new System.Drawing.Point(232, 8); this.btn_OK.Name = "btn_OK"; this.btn_OK.Size = new System.Drawing.Size(136, 24); this.btn_OK.TabIndex = 5; this.btn_OK.Text = "确定并隐藏"; this.btn_OK.TextAlign = System.Drawing.ContentAlignment.TopCenter; this.btn_OK.Click += new System.EventHandler(this.btn_OK_Click); // // timer1 // this.timer1.Interval = 1000; this.timer1.Tick += new System.EventHandler(this.timer1_Tick); // // Form1 // this.AutoScaleBaseSize = new System.Drawing.Size(8, 18); this.ClientSize = new System.Drawing.Size(386, 250); this.Controls.AddRange(new System.Windows.Forms.Control[] { this.btn_OK, this.textBox1, this.label2, this.label1, this.ndMinute, this.ndHour}); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; this.MaximizeBox = false; this.Name = "Form1"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "提醒工具"; ((System.ComponentModel.ISupportInitialize)(this.ndHour)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.ndMinute)).EndInit(); this.ResumeLayout(false); } #endregion /// <summary> /// 应用程序的主入口点。 /// </summary> [STAThread] static void Main() { Application.Run(new Form1()); } private System.DateTime dtDes;// 定时周期的检查是否到了提醒的时间了。 private void timer1_Tick(object sender, System.EventArgs e) { if (DateTime.Now > dtDes) { timer1.Enabled = false; this.Show(); this.Activate(); } } // 确定提醒的时间,然后隐藏该工具。 private void btn_OK_Click(object sender, System.EventArgs e) { dtDes = new DateTime( DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day, (int)ndHour.Value, (int)ndMinute.Value, 0,0); timer1.Enabled = true; this.Hide(); } }} session保存的信息过一段时间久丢失 如何用C# 打开默认浏览器后,最小化浏览器 C# MDI窗体间传值问题 求教:一按TAB键就弹出当前控件的NAME和TABINDEX 跪求一类似360界面的源码(只是界面,用WPF) C#网络编程方面的资料,主要是UdpClient 关于多线城同时启动的问题! 这样一个数据结构,怎么用数据集来对它的某个实例进行绑定?求助!!! 如何按指定字节长度读取文本文件 作品完成!!散分!!!!!想拿它来找工作,热心人帮推荐一个好工作吧!!! Visual Stadio.net 2003问题!!!郁闷中! 怎樣才能學好C#,asp.net;
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;namespace NoticePad
{
/// <summary>
/// 定时提醒的小工具。
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.Timer timer1;
private System.Windows.Forms.NumericUpDown ndHour;
private System.Windows.Forms.NumericUpDown ndMinute;
private System.Windows.Forms.Button btn_OK;
private System.ComponentModel.IContainer components; public Form1()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent(); //
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
} /// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
} #region Windows Form Designer generated code
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.ndHour = new System.Windows.Forms.NumericUpDown();
this.ndMinute = new System.Windows.Forms.NumericUpDown();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.textBox1 = new System.Windows.Forms.TextBox();
this.btn_OK = new System.Windows.Forms.Button();
this.timer1 = new System.Windows.Forms.Timer(this.components);
((System.ComponentModel.ISupportInitialize)(this.ndHour)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.ndMinute)).BeginInit();
this.SuspendLayout();
//
// ndHour
//
this.ndHour.Location = new System.Drawing.Point(8, 8);
this.ndHour.Maximum = new System.Decimal(new int[] {
23,
0,
0,
0});
this.ndHour.Name = "ndHour";
this.ndHour.Size = new System.Drawing.Size(48, 25);
this.ndHour.TabIndex = 0;
//
// ndMinute
//
this.ndMinute.Location = new System.Drawing.Point(112, 8);
this.ndMinute.Maximum = new System.Decimal(new int[] {
59,
0,
0,
0});
this.ndMinute.Name = "ndMinute";
this.ndMinute.Size = new System.Drawing.Size(48, 25);
this.ndMinute.TabIndex = 1;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(64, 16);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(21, 18);
this.label1.TabIndex = 2;
this.label1.Text = "时";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(176, 16);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(21, 18);
this.label2.TabIndex = 3;
this.label2.Text = "分";
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(8, 40);
this.textBox1.Multiline = true;
this.textBox1.Name = "textBox1";
this.textBox1.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
this.textBox1.Size = new System.Drawing.Size(368, 200);
this.textBox1.TabIndex = 4;
this.textBox1.Text = "写入提醒的内容......";
//
// btn_OK
//
this.btn_OK.Location = new System.Drawing.Point(232, 8);
this.btn_OK.Name = "btn_OK";
this.btn_OK.Size = new System.Drawing.Size(136, 24);
this.btn_OK.TabIndex = 5;
this.btn_OK.Text = "确定并隐藏";
this.btn_OK.TextAlign = System.Drawing.ContentAlignment.TopCenter;
this.btn_OK.Click += new System.EventHandler(this.btn_OK_Click);
//
// timer1
//
this.timer1.Interval = 1000;
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(8, 18);
this.ClientSize = new System.Drawing.Size(386, 250);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.btn_OK,
this.textBox1,
this.label2,
this.label1,
this.ndMinute,
this.ndHour});
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.MaximizeBox = false;
this.Name = "Form1";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "提醒工具";
((System.ComponentModel.ISupportInitialize)(this.ndHour)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.ndMinute)).EndInit();
this.ResumeLayout(false); }
#endregion /// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
} private System.DateTime dtDes;// 定时周期的检查是否到了提醒的时间了。
private void timer1_Tick(object sender, System.EventArgs e)
{
if (DateTime.Now > dtDes)
{
timer1.Enabled = false;
this.Show();
this.Activate();
}
} // 确定提醒的时间,然后隐藏该工具。
private void btn_OK_Click(object sender, System.EventArgs e)
{
dtDes = new DateTime(
DateTime.Today.Year,
DateTime.Today.Month,
DateTime.Today.Day,
(int)ndHour.Value,
(int)ndMinute.Value,
0,0);
timer1.Enabled = true;
this.Hide();
}
}
}