日期:2014-05-17  浏览次数:20816 次

C# 画的圆显示不出来
代码如下:
  private void drawClock(int h, int m, int s)
  {  
  Graphics graphic = this.CreateGraphics();
  Rectangle rect = new Rectangle(30, 76, 180, 180);

  graphic.Clear(Color.White);

  Pen myPen = new Pen(Color.Black, 1);
  graphic.DrawEllipse(myPen, rect.Width/2,rect.Height/2,180,180);//画表盘
  }
不知道为什么表盘总是画不出来

------解决方案--------------------
C# code
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 WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        private void drawClock()
        {
            Graphics graphic = this.CreateGraphics();
            Rectangle rect = new Rectangle(30, 76, 180, 180);

            graphic.Clear(Color.White);

            Pen myPen = new Pen(Color.Black, 1);
            graphic.DrawEllipse(myPen, rect.Width / 2, rect.Height / 2, 180, 180);//画表盘
        }

        private void Form1_Paint(object sender, PaintEventArgs e)
        {
            drawClock();
        }
    }
}

------解决方案--------------------
探讨
C# code

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……