[.NET]graphics繪圖

看板Visual_Basic作者 (bright)時間12年前 (2013/07/24 16:28), 編輯推噓0(004)
留言4則, 1人參與, 最新討論串1/1
各位好 我用VS2012 visual 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.Threading.Tasks; using System.Windows.Forms; namespace WindowsFormsApplication6 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { } private void button1_Click(object sender, EventArgs e) { } private void Form1_Paint(object sender, PaintEventArgs e) { Graphics G = e.Graphics; // 取得畫布方法二 G.DrawLine(Pens.Black, 0, 0, 100, 100); //在 Form1 的畫布上畫直線 } } } 按下play之後 卻沒有畫出線條.. 這是我看書上的範例 請問 哪裡出現問題了嗎? 謝謝 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 111.185.90.33

07/24 18:13, , 1F
我知道為什麼了^^
07/24 18:13, 1F

07/24 18:13, , 2F
因為我沒有加上這句
07/24 18:13, 2F

07/24 18:14, , 3F
this.Paint += new System.Windows.Forms.
07/24 18:14, 3F

07/24 18:14, , 4F
PaintEventHandler(this.Form1_Paint);
07/24 18:14, 4F
文章代碼(AID): #1Hxv0yDb (Visual_Basic)
文章代碼(AID): #1Hxv0yDb (Visual_Basic)