Hi,

Is it possible to use the System.Drawing.Graphics methods without having to put code in the control's Paint event? If so, how?

-James

Member Avatar for iamthwee

What are you trying to do?

yes it is possible

private void button1_Click(object sender, EventArgs e)
        {
            Graphics g = this.CreateGraphics();
            Pen pe = new Pen(Color.Black);
            Point pt1 = new Point(125, 80);
            Point pt2 = new Point(125, 150);
            g.DrawLine(pe, pt1, pt2);
        }

u do need to declare

using System.Drawing;

at the top


i hope this helps

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.