2
Answers

Coupon Code and cash back which are uses in e-commerces

How to Use/Generate Discount Coupon Code and Cash Back  in ASP .Net Application.
Answers (2)
0
Vulpes
NA 98.3k 1.5m 11y
The form's constructor runs before the form has loaded.

When the form loads, the Paint events for the form and its controls fire. Unfortunately, these events erase anything that has been drawn with a Graphics object derived from the CreateGraphics() method and so you don't see it.

Check this link for confirmation:

http://msdn.microsoft.com/en-us/library/system.windows.forms.control.creategraphics(v=vs.110).aspx

Incidentally, when you use CreateGraphics, you should always call Dispose() on the Graphics object to get rid of the underlying unmanaged resources. So I'd change your code to this:

        private void button1_Click(object sender, EventArgs e)
        {
            Rectangle r = new Rectangle(2, 2, 20, 10); //left,top,width,heigth
            Graphics g = pictureBox1.CreateGraphics();
            g.FillRectangle(Brushes.Red, r);
            g.Dispose();
        }
Accepted
0
Rob Sobol
NA 9 4.3k 11y


Works like a charm !

Problem solved !

WhooHoo !