我也是新手,不知現在學C#好,還是學java好。希望各路高手指點。
呵呵:>

解决方案 »

  1.   

    protected override void OnPaint(PaintEventArgs e)
    {
    ........
    }
    会自动刷新的
      

  2.   

    一般来说,如果在OnPaint以外进行绘制,有可能切换、缩放界面以后就看不到了。如果要实现LZ的这个功能,可以用Timer每隔一段时间执行一次。
    using System;
    using System.Drawing;
    using System.Collections;
    using System.ComponentModel;
    using System.Windows.Forms;
    using System.Data;namespace WindowsApplication1
    {
    /// <summary>
    /// Summary description for Form1.
    /// </summary>
    public class Form1 : System.Windows.Forms.Form
    {
    private System.Windows.Forms.Timer timer1;
    private System.ComponentModel.IContainer components; public Form1()
    {
    //
    // Required for Windows Form Designer support
    //
    InitializeComponent(); //
    // TODO: Add any constructor code after InitializeComponent call
    //
    } /// <summary>
    /// Clean up any resources being used.
    /// </summary>
    protected override void Dispose( bool disposing )
    {
    if( disposing )
    {
    if (components != null) 
    {
    components.Dispose();
    }
    }
    base.Dispose( disposing );
    } #region Windows Form Designer generated code
    /// <summary>
    /// Required method for Designer support - do not modify
    /// the contents of this method with the code editor.
    /// </summary>
    private void InitializeComponent()
    {
    this.components = new System.ComponentModel.Container();
    this.timer1 = new System.Windows.Forms.Timer(this.components);
    // 
    // timer1
    // 
    this.timer1.Enabled = true;
    this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
    // 
    // Form1
    // 
    this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
    this.ClientSize = new System.Drawing.Size(292, 266);
    this.Name = "Form1";
    this.Text = "Form1";
    this.Paint += new System.Windows.Forms.PaintEventHandler(this.Form1_Paint); }
    #endregion /// <summary>
    /// The main entry point for the application.
    /// </summary>
    [STAThread]
    static void Main() 
    {
    Application.Run(new Form1());
    } private int pos = 0; private void Form1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
    {
    // calc a point 
    if (e.ClipRectangle.IsEmpty)
    return ; // center point
    Rectangle r = this.ClientRectangle;
    Point p1 = new Point(r.Left + r.Width / 2, 
    r.Top + r.Height / 2);
    // another point
    double x = p1.X + Math.Cos(Math.PI * pos / 180.0) * (r.Width / 2 - 20);
    double y = p1.Y + Math.Sin(Math.PI * pos / 180.0) * (r.Width / 2 - 20);
    Point p2 = new Point((int)x, (int)y);
    // draw line
    e.Graphics.DrawLine(Pens.Navy, p1, p2);
    } private void timer1_Tick(object sender, System.EventArgs e)
    {
    pos += 3;
    // using residue number
    pos = pos % 360;
    // redraw this form
    this.Invalidate();
    } }
    }
      

  3.   

    用timer控件,里面有个tick的属性,就是每隔多长时间执行一次命令
      

  4.   

    如果是做的是WinForm窗体,加一个Timer控件,在控件栏中可以找到这个控件,Timer控件中的Interval属性是设置循环事件的间隔,单位为毫秒,1秒=1000毫秒,Timer还有一个Tick事件,那是循环时所要调用的事件,在这个事件中写你要调用的代码,就可以实现你的要求了。
      

  5.   

    你也可以用线程,里面有个sleep(要间隔的时间)方法,在线程里调用就可以了