我这样怎么不显示图出来?
public Form1()
{
InitializeComponent();
Pen pen = new Pen(Color.Red);
pen.Width = 5;
//Graphics gr = this.CreateGraphics();
this.CreateGraphics().DrawEllipse(new Pen(Color.Red), 125 - 5, 130 - 5, 2 * 5, 2 * 5);
}
public Form1()
{
InitializeComponent();
Pen pen = new Pen(Color.Red);
pen.Width = 5;
//Graphics gr = this.CreateGraphics();
this.CreateGraphics().DrawEllipse(new Pen(Color.Red), 125 - 5, 130 - 5, 2 * 5, 2 * 5);
}
解决方案 »
- C# 获取Excel一个单元格的值,如果这个值为时间格式,获取出来的值怎么会是文本格式?求高手
- 一个winform的UI问题
- VS2008 GridView绑定的奇怪问题?
- 写资源管理器盘符或是里面的文件夹访问受限要调用哪个类来解决啊??
- socket 传输问题,请帮忙!
- 求教:中文字符padright时的问题
- 了解单键模式工厂朋友进~~~~~~求助了
- c#正则问题
- vs2003的c#的文件类对二进制文件写和borland c builder的写是不是一样的呀?
- 元数据? 如何走.net 这条路
- 求助 VC#2005下水晶报表的部署方法!
- C#显示数据都是这样的“5.04E-06”,如何显示成0.00000504
下面两种方法可以任选一种试试看
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();
//方法1
Bitmap img = new Bitmap(this.Width, this.Height);
Graphics g = Graphics.FromImage(img);
Pen pen = new Pen(Color.Red);
pen.Width = 5;
g.DrawEllipse(new Pen(Color.Red), 125 - 5, 130 - 5, 2 * 5, 2 * 5);
this.BackgroundImage = img;
} private void Form1_Paint(object sender, PaintEventArgs e)
{
//方法2
Pen pen = new Pen(Color.Red);
pen.Width = 5;
//Graphics gr = this.CreateGraphics();
this.CreateGraphics().DrawEllipse(new Pen(Color.Red), 125 - 5, 130 - 5, 2 * 5, 2 * 5); }
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;namespace DeviceApplication3
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
aa();
} private void button1_Click(object sender, EventArgs e)
{
aa();
} private void Form1_Load(object sender, EventArgs e)
{
aa();
}
void aa() {
Pen pen = new Pen(Color.Red);
pen.Width = 5;
//Graphics gr = this.CreateGraphics();
this.CreateGraphics().DrawEllipse(new Pen(Color.Red), 125 - 5, 130 - 5, 2 * 5, 2 * 5);
}
}
}
{
Pen pen = new Pen(Color.Red);
pen.Width = 5;
//Graphics gr = this.CreateGraphics();
this.CreateGraphics().DrawEllipse(new Pen(Color.Red), 125 - 5, 130 - 5, 2 * 5, 2 * 5); }