首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

C# 画的圆展示不出来

2012-11-09 
C# 画的圆显示不出来代码如下:private void drawClock(int h, int m, int s){Graphics graphic this.Cre

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

热点排行