标题:运行后没有图像!谢谢!
取消只看楼主
jay520
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2011-2-11
结帖率:83.33%
已结贴  问题点数:20 回复次数:2 
运行后没有图像!谢谢!
using System;
using System.Collections.Generic;
using
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace basicgraphic
{
    public partial class frmMain : Form
    {
        int fg;
        public frmMain()
        {
            InitializeComponent();
        }

        private void btnClear_Click(object sender, EventArgs e)
        {
            fg = 0;
            this.Invalidate();
        }
        private void btnCir_Click(object sender, EventArgs e)
        {
            fg = 1;
            this.Invalidate();
        }
        private void btnEllipse_Click(object sender, EventArgs e)
        {

            fg = 2;
            this.Invalidate();
        }
        private void btnPie_Click(object sender, EventArgs e)
        {

            fg = 3;
            this.Invalidate();
        }

        private void btnLine_Click(object sender, EventArgs e)
        {

            fg = 4;
            this.Invalidate();
        }

        private void btnArc_Click(object sender, EventArgs e)
        {

            fg = 5;
            this.Invalidate();
        }

        private void btn_Click(object sender, EventArgs e)
        {

            fg = 6;
            this.Invalidate();
        }

        private void panel1_Paint(object sender, PaintEventArgs e)
        {
            Graphics g = this.CreateGraphics();
            Pen pen1 = new Pen(Color.Blue, 3);
            switch (fg)
            {
                case 0:
                    g.Clear(Color.Gainsboro);
                    break;
                case 1:
                    g.DrawEllipse(pen1, 50, 50, 150, 150);
                    break;

                case 2:
                    g.DrawEllipse(pen1, 50, 50, 300, 200);
                    break;
                case 3:
                    g.DrawLine(pen1, 50, 100, 300, 100);
                    break;
                case 4:
                    g.DrawArc(pen1, 50, 50, 200, 300, 180, 90);
                    break;
                case 5:
                    g.DrawRectangle(pen1, 50, 50, 200, 150);
                    break;
                case 6:
                    g.DrawPie(pen1, 100, 100, 300, 200, 225, 90);
                    break;
            }
        }
    }
}
windows应用程序 7个Button 1.btnClear  清除2.btnCir 圆 3.btnEllipse 椭圆 4.benPie扇形   5.btnLine 直线6.btnArc弧线 7.btn矩形  
还有我自己加了个panel..书本没的!还有private void panel1_Paint(object sender, PaintEventArgs e) 书本这句是
private void femMain_Paint(object sender, PaintEventArgs e)
生成成功..却运行不出图像!点解!
搜索更多相关主题的帖子: private 
2011-03-09 20:57
jay520
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2011-2-11
得分:0 
回复 2楼 xydddaxia
basicgraphic frmMain 并不包含Pen1
2011-03-10 19:14
jay520
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2011-2-11
得分:0 
回复 5楼 vxbb
这两个句子貌似不能同时用!e重哪里来的!
2011-03-10 19:20



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-333683-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 1.386582 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved