0

I am new to here as well to c#, I am trying to draw the rectangular graphics for for around the button but unfortunately after placing the group box it is not visible i tried with send back and bring front options still no effective result, if i remove the group box from the form this will draw rectangle and visible in form.

Looking for possible solution from experts.

 System.Drawing.Graphics graphicsobj;
        graphicsobj = this.CreateGraphics();
        Pen mypen = new Pen(System.Drawing.Color.Red, 5);
        int x1[enter image description here][1] = button1.Location.X;
        int y1 = button1.Location.Y;
        int width1 = button1.Width;
        int height1 = button1.Height;
        graphicsobj.DrawRectangle(mypen, x1, y1, width1, height1);
  • _graphicsobj = this.CreateGraphics();_ This is (almost) always a mistake. Use the Paint event and its e.Graphics object! – TaW Jan 28 '17 at 08:23
  • I tried with your method, if I remove group box I can able to generate graphics else I is nothing – Vinay Krishna Jan 29 '17 at 07:10
  • Did you code the `button1_Paint`event? (And [hook it up?](http://stackoverflow.com/questions/33275763/copy-datagridview-values-to-textbox/33276161?s=14|0.0000#33276161)) Show us the new code! Do include the method headers! – TaW Jan 29 '17 at 09:07

0 Answers0