[問題] 如何每按一下畫一下圖

看板C_Sharp (C#)作者 (奇怪 還沒收到??)時間14年前 (2011/08/20 21:11), 編輯推噓0(003)
留言3則, 2人參與, 最新討論串1/2 (看更多)
請問: 我有寫一畫圖的method: protected override void OnPaint(PaintEventArgs e) { Graphics paint = e.Graphics; //string color = Color.AliceBlue; Pen pen = new Pen(Color.AliceBlue); paint.DrawLine(pen, 272, 301, 91, 127); paint.DrawLine(pen, 91, 127, 167, 103); } 但是我希望我每按button 一下就呼叫一下畫圖的method: OnPaint, 把我載入的圖片(資料結構: picturebox)當argument傳入OnPaint去 但好像行不通>"< private void Draw_CG_Click(object sender, EventArgs e) { OnPaint(plate); //這行行不通,plate是資料結構picturebox的var. } 1. 不知該如何implemnt這樣的方法才好? 2. 我是該從toolbox上抓一個下來裡面default就會有PaintEventArgs, 我就可以 按一下它就在圖上畫一下圖? 若有,為何? 謝謝大家!! -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.115.155.193

08/20 21:25, , 1F
用 Invalidate();
08/20 21:25, 1F

08/20 21:25, , 2F
james願聞其詳....
08/20 21:25, 2F

08/20 22:01, , 3F
你的OnPaint是屬於哪個class?
08/20 22:01, 3F
文章代碼(AID): #1EJx9h-T (C_Sharp)
文章代碼(AID): #1EJx9h-T (C_Sharp)