如题,panel的BackgroundImage已经设置为另一图片,因此不能将所花直线设置为panel的背景.

解决方案 »

  1.   


    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;
    using System.Xml;namespace WindowsApplication7
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
                        }        private void panel1_Paint(object sender, PaintEventArgs e)
            {
                e.Graphics.DrawLine(Pens.Red, new Point(0, 0), new Point(100, 100));
            }
        }
    }