| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 373 人关注过本帖
标题:帮忙了
只看楼主 加入收藏
yangwenkai
Rank: 1
等 级:新手上路
威 望:1
帖 子:74
专家分:0
注 册:2008-9-9
收藏
 问题点数:0 回复次数:2 
帮忙了
看看下边的程序,目的是想在form2中画出图,具体在form2怎么写呢,指点下
using System;
using System.Collections.Generic;
using
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace shap
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void sel_ch(object sender, EventArgs e)
        {
            
            
            switch (comboBox1.Text)
            {
                case "正方形":
                    { label1.Text = "正方形的边长";
                  
                        //a= Convert.ToInt32 (textBox1.Text);
                    label2.Visible = false;
                    textBox2.Visible = false;
                    label3.Visible = false;
                    textBox3.Visible = false;
                  
                        break;
                }
            case "长方形":
                {
                    label1.Text = "长方形的长";
                    //int a = Convert.ToInt32(textBox1.Text);
                    //int b = Convert.ToInt32(textBox2.Text);
                    label2.Text = "长方形的宽";
                    label2.Visible = true;
                    textBox2.Visible = true;

                    label3.Visible = false;
                    textBox3.Visible = false;
                    /*Graphics g = f.pictureBox1.CreateGraphics();
                    Pen pen = new Pen(Color.Red, 2);
                    g.DrawRectangle(pen, 10, 10, a, b);*/
                    break;
                }
                case"圆形":
                    {label1.Text = "圆形的半径";
                       
                    
                    label2.Visible = false;
                    textBox2.Visible = false;
                    label3.Visible = false;
                    textBox3.Visible = false;
                  
                        break;
                    }
               
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            this.Hide();

            Form2 f = new Form2();
            f.ShowDialog();
            f.Show();
            Graphics g = f.pictureBox1.CreateGraphics();
            Pen pen = new Pen(Color.Red, 2);
            int a = Convert.ToInt32(textBox1.Text);
            int b = Convert.ToInt32(textBox2.Text);


            switch (comboBox1.Text)
            {
                case "正方形":
                    {
                       
                        g.DrawRectangle(pen, 10, 10,a, a);
                        break;
                    }
                case "长方形":
                    {

                        g.DrawRectangle(pen, 10, 10, a, b);
                        break;
                    }
                case "圆":
                    {
                        g.DrawEllipse(pen, 10, 10, a, a);
                        break;
                    }

            }
        }
    }
}
搜索更多相关主题的帖子: public private void 
2008-10-07 10:25
师妃暄
Rank: 6Rank: 6
等 级:贵宾
威 望:27
帖 子:805
专家分:107
注 册:2006-3-1
收藏
得分:0 
现在怎么GDI的问题变这么多了...

看来要人写专题解决了..

有实力才会有魅力 实力来自坚持不懈的努力
2008-10-07 10:27
candy110
Rank: 1
等 级:新手上路
帖 子:146
专家分:0
注 册:2008-9-25
收藏
得分:0 
难,让版主给你解决吧
2008-10-07 10:33
快速回复:帮忙了
数据加载中...
 
   



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

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