C#时钟问题 求c#时钟源代码 谢谢 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 http://www.cnpopsoft.com/article.asp?id=53 首先导入timer 将其Interval 属性值改为1000再点击timer的Tick 事件 private void timer1_Tick(object sender, EventArgs e) { this.toolStripStatusLabel2.Text = "当前时间:" + DateTime.Now.ToString(); } 代码如下:using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;namespace 运行的时钟{ public partial class Form1 : Form { const int s_pinlen = 100; const int m_pinlen = 75; const int h_pinlen = 50; public Form1() { InitializeComponent(); } private void pictureBox1_Click(object sender, EventArgs e) { } public void myClock(int h, int m, int s) { Graphics myGraphics = pictureBox1.CreateGraphics(); myGraphics.Clear(Color .White ); Pen mypen = new Pen(Color .Black ,1); myGraphics.DrawEllipse(mypen ,pictureBox1 .ClientRectangle); Point CPoint = new Point(pictureBox1 .ClientRectangle .Width /2,pictureBox1 .ClientRectangle .Height /2); Point SPoint = new Point((int)(CPoint .X +(Math .Sin(6*s*Math .PI /180))* s_pinlen),(int)(CPoint .Y -(Math .Cos (6*s *Math .PI /180))*s_pinlen)); Point MPoint = new Point((int )(CPoint .X +(Math .Sin (6*m*Math .PI /180))*m_pinlen),(int )(CPoint .Y -(Math.Cos (6*m*Math .PI /180))*m_pinlen )); Point HPoint = new Point((int)(CPoint.X + (Math.Sin(((30*h)+(m/2))*Math .PI /180))*h_pinlen),(int)(CPoint .Y -(Math .Cos (((30*h)+(m/2))*Math .PI /180))*h_pinlen)); myGraphics.DrawLine(mypen ,CPoint ,SPoint ); mypen = new Pen(Color .Black ,2); myGraphics.DrawLine(mypen ,CPoint ,MPoint ); mypen = new Pen(Color .Black ,4); myGraphics.DrawLine(mypen ,CPoint ,HPoint ); } private void timer1_Tick(object sender, EventArgs e) { int h = DateTime.Now.Hour; int m = DateTime.Now.Minute; int s = DateTime.Now.Second; myClock(h, m, s); this.Text = "现在的时间是:"+ h.ToString ()+":"+m.ToString ()+";"+s.ToString () ; } } }窗体上设置12个label控件,命名1到12,并且排成圆形即可。再拖一个Timer控件,将其Interval 属性值改为1000,Enabled属性改成true,就行了 DrawLine 指针 再画个圆 自己画一个 用js啊 文档里有很多 特效啊 想要哪种 时钟?js特效 文档需要联系 怎么将listview中的列改行啊 我不让Textbox为空或NULL或空格,如何检测? 用contextMenustrip实现右键菜单在ActiveX中无法显示出来 ###哪位大侠来帮我看看关于表单提交时汉字不能正常读取的问题!!! setGateWay这个方法是在哪个Dll中? C# 使光标无法选中文本框 哪位高手指导一下.关于数据库的一些操作! 怎样从一个Directory中取得文件夹的名称? 嵌入EXCEL到Winfrom.From C#如何调用Delphi窗体 c# filesystemwatcher 监控文件是否写完 C#代码与用户交互(web)
再点击timer的Tick 事件 private void timer1_Tick(object sender, EventArgs e)
{
this.toolStripStatusLabel2.Text = "当前时间:" + DateTime.Now.ToString(); }
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;namespace 运行的时钟
{
public partial class Form1 : Form
{
const int s_pinlen = 100;
const int m_pinlen = 75;
const int h_pinlen = 50;
public Form1()
{
InitializeComponent();
} private void pictureBox1_Click(object sender, EventArgs e)
{ }
public void myClock(int h, int m, int s)
{
Graphics myGraphics = pictureBox1.CreateGraphics();
myGraphics.Clear(Color .White );
Pen mypen = new Pen(Color .Black ,1);
myGraphics.DrawEllipse(mypen ,pictureBox1 .ClientRectangle);
Point CPoint = new Point(pictureBox1 .ClientRectangle .Width /2,pictureBox1 .ClientRectangle .Height /2); Point SPoint = new Point((int)(CPoint .X +(Math .Sin(6*s*Math .PI /180))* s_pinlen),(int)(CPoint .Y -(Math .Cos (6*s *Math .PI /180))*s_pinlen)); Point MPoint = new Point((int )(CPoint .X +(Math .Sin (6*m*Math .PI /180))*m_pinlen),(int )(CPoint .Y -(Math.Cos (6*m*Math .PI /180))*m_pinlen )); Point HPoint = new Point((int)(CPoint.X + (Math.Sin(((30*h)+(m/2))*Math .PI /180))*h_pinlen),(int)(CPoint .Y -(Math .Cos (((30*h)+(m/2))*Math .PI /180))*h_pinlen)); myGraphics.DrawLine(mypen ,CPoint ,SPoint );
mypen = new Pen(Color .Black ,2);
myGraphics.DrawLine(mypen ,CPoint ,MPoint );
mypen = new Pen(Color .Black ,4);
myGraphics.DrawLine(mypen ,CPoint ,HPoint );
} private void timer1_Tick(object sender, EventArgs e)
{
int h = DateTime.Now.Hour;
int m = DateTime.Now.Minute;
int s = DateTime.Now.Second;
myClock(h, m, s);
this.Text = "现在的时间是:"+ h.ToString ()+":"+m.ToString ()+";"+s.ToString () ;
}
}
}
窗体上设置12个label控件,命名1到12,并且排成圆形即可。再拖一个Timer控件,将其Interval 属性值改为1000,Enabled属性改成true,就行了
再画个圆 自己画一个
需要联系