title: Drawing a rectangle over panel
body: <p>I need to draw a rectangle into a panel. I dont know the color in advance, I get the color during runtime, I dont know how to set the color not to a fixed value, and second - when i try to draw the rectangle, it does nothing at all. Here is my code that should draw the rectangle (infact it does in another project, but thats just in a plain form, not into a panel)  </p>
  
  <pre><code>    Graphics g;  
      g = CreateGraphics();  
      Pen p;  
      Rectangle r;  
      p = new Pen(Brushes.Blue); 
      r = new Rectangle(1, 1, 578, 38);  
      g.DrawRectangle(p, r);`  
  </code></pre>
  
  <p>So I need to replace (Brushes.Blue) with a variable and I need to draw the rectangle in a panel on its coordinates set in this code..</p>