我在Form窗口上放了一个TabControl控件怎么在tabControl控件上 绘制一条直线。小弟初学,小菜鸟一个希望各位朋友帮忙

解决方案 »

  1.   

     
    bang 你顶1下。。
      

  2.   

    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;
    using System.IO;namespace 老师的画图工具
    {
        public partial class Form1 : Form
        {
            Point p1;
            Point p2;
            Point pOver;
            Graphics gShow;
            Pen pen;
            bool isOver;
            Bitmap bitShow;
            Graphics gSave;
            int type = 0;
            public Form1()
            {
                InitializeComponent();
                gShow = pictureBox1.CreateGraphics();
                pen = new Pen(Color.Black);
            }
            
            private void 新建ToolStripMenuItem_Click(object sender, EventArgs e)
            {
                pictureBox1.Image = null;
            }        private void 打开ToolStripMenuItem_Click(object sender, EventArgs e)
            {
                openFileDialog1.Filter = "图片|*.jpg";
                openFileDialog1.ShowDialog();
                string path = openFileDialog1.FileName;
                FileStream fs = new FileStream(path, FileMode.Open);
                bitShow = new Bitmap(fs);
                fs.Close();
                pictureBox1.Image = bitShow;
                gSave = Graphics.FromImage(bitShow);
            }        private void 保存ToolStripMenuItem_Click(object sender, EventArgs e)
            {
                saveFileDialog1.ShowDialog();
                string path = saveFileDialog1.FileName;
                bitShow.Save(path);
            }        private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
            {
                if (e.Button == MouseButtons.Left)
                {                isOver = true;
                    p1.X = e.X;
                    p1.Y = e.Y;
                }
            }        private void pictureBox1_MouseMove(object sender, MouseEventArgs e)
            {
                if (isOver)
                {
                    if (type == 0)
                    {
                        p2.X = e.X;
                        p2.Y = e.Y;
                        gShow.DrawLine(pen, p1, p2);
                        gSave.DrawLine(pen, p1, p2);
                        p1.X = e.X;
                        p1.Y = e.Y;
                    }
                }
            }        private void pictureBox1_MouseUp(object sender, MouseEventArgs e)
            {
                isOver = false;
                pOver.X = e.X;
                pOver.Y = e.Y;
                if (type == 1)
                {
                    gShow.DrawEllipse(pen, p1.X, p1.Y, (pOver.X - p1.X), (pOver.Y - p1.Y));
                }
            }
        }
    }
    这是在pictureBox1上画的你可以试着修改下