Click here to Skip to main content
15,908,166 members
Home / Discussions / C#
   

C#

 
GeneralRe: How to obtain drive letters without checking the diskette? Pin
Dan Neely8-Mar-06 7:53
Dan Neely8-Mar-06 7:53 
AnswerRe: How to obtain drive letters without checking the diskette? Pin
Tom Wright8-Mar-06 7:20
Tom Wright8-Mar-06 7:20 
AnswerRe: How to obtain drive letters without checking the diskette? Pin
Guffa8-Mar-06 9:02
Guffa8-Mar-06 9:02 
GeneralRe: How to obtain drive letters without checking the diskette? Pin
Libor Tinka8-Mar-06 10:49
Libor Tinka8-Mar-06 10:49 
AnswerRe: How to obtain drive letters without checking the diskette? Pin
Steve Hansen9-Mar-06 3:32
Steve Hansen9-Mar-06 3:32 
GeneralRe: How to obtain drive letters without checking the diskette? Pin
Libor Tinka9-Mar-06 6:20
Libor Tinka9-Mar-06 6:20 
Questionhow to convert a physical address to a virtual address? Pin
bharadwaj_r8-Mar-06 6:36
bharadwaj_r8-Mar-06 6:36 
AnswerRe: how to convert a physical address to a virtual address? Pin
Judah Gabriel Himango8-Mar-06 7:14
sponsorJudah Gabriel Himango8-Mar-06 7:14 
GeneralRe: how to convert a physical address to a virtual address? Pin
bharadwaj_r8-Mar-06 19:22
bharadwaj_r8-Mar-06 19:22 
GeneralRe: how to convert a physical address to a virtual address? Pin
Judah Gabriel Himango9-Mar-06 5:00
sponsorJudah Gabriel Himango9-Mar-06 5:00 
QuestionWhat are these WndProc WMs? Pin
redfish348-Mar-06 6:25
redfish348-Mar-06 6:25 
AnswerRe: What are these WndProc WMs? Pin
Dan Neely8-Mar-06 7:15
Dan Neely8-Mar-06 7:15 
GeneralRe: What are these WndProc WMs? Pin
redfish348-Mar-06 22:03
redfish348-Mar-06 22:03 
AnswerRe: What are these WndProc WMs? Pin
Le centriste8-Mar-06 15:14
Le centriste8-Mar-06 15:14 
QuestionAutoscroll to a rectangle drawn in paint event Pin
Gulfraz Khan8-Mar-06 5:19
Gulfraz Khan8-Mar-06 5:19 
QuestionFile Icon Pin
Mr Marchepane8-Mar-06 4:52
Mr Marchepane8-Mar-06 4:52 
AnswerRe: File Icon Pin
redfish348-Mar-06 6:31
redfish348-Mar-06 6:31 
QuestionWebservices (RPC+SOAP) Pin
mpuerto8-Mar-06 4:20
mpuerto8-Mar-06 4:20 
QuestionTableLayoutPanel question Pin
Drew McGhie8-Mar-06 4:10
Drew McGhie8-Mar-06 4:10 
QuestionGraphics in C# Pin
Jeea20068-Mar-06 3:42
Jeea20068-Mar-06 3:42 
AnswerRe: Graphics in C# Pin
Judah Gabriel Himango8-Mar-06 3:55
sponsorJudah Gabriel Himango8-Mar-06 3:55 
GeneralRe: Graphics in C# Pin
Jeea200618-Mar-06 22:49
Jeea200618-Mar-06 22:49 
AnswerRe: Graphics in C# Pin
_awatts8-Mar-06 9:05
_awatts8-Mar-06 9:05 
GeneralRe: Graphics in C# Pin
Jeea200618-Mar-06 23:01
Jeea200618-Mar-06 23:01 
AnswerRe: Graphics in C# Pin
_awatts20-Mar-06 9:53
_awatts20-Mar-06 9:53 
Wajeeha,

My following answer assumes you're drawing to a form.

Basically you want to perform your drawing within the Form's Paint event or override the Form's OnPaint method? not to draw directly to the form when a button is pressed. The Paint event will receive the PaintEventArgs referenced by 'e'. It's by using e.Graphics you will perform the necessary drawing. Based on your original request of altering the angle/rotation or a box when the user presses a button, I would have done something like this (although very basic)

<br />
int _x = 10;<br />
int _y = 10;<br />
int _width = 100;<br />
int _height = 100;<br />
int _angle = 45;<br />
...<br />
...<br />
...<br />
private void buttonclicked( object sender System.EventArgs e )<br />
{<br />
  _angle = ( _angle == 360 ) ? 0 ? _angle + 1;<br />
  this.Refresh();<br />
}<br />
<br />
<br />
private void FormPaint( object sender, PaintEventArgs e )<br />
{<br />
  Graphics g = e.Graphics;<br />
  Matrix matrix = new Matrix();<br />
  matrix.Rotate( _angle );<br />
  g.Transform = matrix;<br />
  g.DrawRectangle( Pens.Black, _x, _y, _width, _height );<br />
}<br />


Everytime the button is pressed, we update the rotation angle and force a redraw of the box.

Regards,

Andy

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.