dcsimg
Results 1 to 4 of 4

Thread: [RESOLVED] Graphics problem

  1. #1

    Thread Starter
    Addicted Member BSA01's Avatar
    Join Date
    Apr 2009
    Location
    Bosnia and Herzegovina
    Posts
    146

    Resolved [RESOLVED] Graphics problem

    I have form that should show rectangles. Also, there are few text boxes. If I put some text into first text box and press TAB key, all rectangles disappear. Why this is so ?

    I am using this technique for drawing :

    Code:
    Graphics BackG;
    
    BackG = this.CreateGraphics();
    
    BackG.drawRectangle(pen,size,....);
    How can I fix this issue ?

  2. #2
    coder. Lord Orwell's Avatar
    Join Date
    Feb 2001
    Location
    Elberfeld, IN
    Posts
    7,590

    Re: Graphics problem

    i would guess windows is redrawing the window, and you didn't put your rectangle code in the window paint function. Windows will redraw the window whenever it thinks the display has been invalidated and if your rectangle isn't redrawn at the same time it will go away. You will probably have the same effect if you drag a window over the top of that one then take it off of it again.

  3. #3
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    104,193

    Re: Graphics problem

    You should basically never be calling CreateGraphics. The only time you should be drawing on a control is on its Paint event, i.e. either in a Paint event handler or in a form or custom control's OnPaint method. In either case, there's an 'e' parameter that has a Graphics property. It's that Graphics object that you use to draw on the form/control. You can check out a couple of examples by following the CodeBank link in my signature and checking out any of the threads about drawing.

  4. #4

    Thread Starter
    Addicted Member BSA01's Avatar
    Join Date
    Apr 2009
    Location
    Bosnia and Herzegovina
    Posts
    146

    Re: Graphics problem

    Thank you for your answers. I resolved problem using Rectangle shape and Shape container.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width