Click here to Skip to main content
15,886,919 members
Home / Discussions / C#
   

C#

 
GeneralRe: Custom Open Dialogs with WebBrowser Control Pin
Umer Sheikh5-Mar-09 17:07
Umer Sheikh5-Mar-09 17:07 
QuestionUsing IAccessible to navigate across Datagrid rows Pin
Brian Garnica5-Mar-09 11:35
Brian Garnica5-Mar-09 11:35 
QuestionGraphs disappear from panel Pin
StuffyEst5-Mar-09 10:58
StuffyEst5-Mar-09 10:58 
AnswerRe: Graphs disappear from panel Pin
Calin Tatar5-Mar-09 11:27
Calin Tatar5-Mar-09 11:27 
GeneralRe: Graphs disappear from panel Pin
StuffyEst5-Mar-09 11:54
StuffyEst5-Mar-09 11:54 
GeneralRe: Graphs disappear from panel Pin
Calin Tatar5-Mar-09 12:07
Calin Tatar5-Mar-09 12:07 
GeneralRe: Graphs disappear from panel Pin
StuffyEst5-Mar-09 12:24
StuffyEst5-Mar-09 12:24 
AnswerRe: Graphs disappear from panel Pin
Luc Pattyn5-Mar-09 12:06
sitebuilderLuc Pattyn5-Mar-09 12:06 
Hi,

here are a few simple rules that should guide you:

there are several steps to draw something so it becomes visible on the screen:

1.
decide upon what object you want to draw; it normally is a Control (e.g. a Panel) or a
Form itself. I prefer to add a Panel to a Form, then draw on the Panel.

2.
create some variables (Rectangle, struct, class, whatever) that hold the parameters of
your drawing. For a rectangle that could be top and left coordinate, and width+height,
or just a Rectangle. etc.

3.
create a Paint handler (either add your own paint handler to the Paint event, or
override the OnPaint method) for that Panel, and do all your drawing in there,
using the Graphics class and your variables.

4.
when you want to change things, modify the variables and call Panel.Invalidate() or
one of its overloads (for selective invalidation).
5.
If you want to animate things, perform the move (step 4) inside the Tick handler
of a Windows.Forms.Timer

BTW: if you need to create some objects (Fonts, Pens, Brushes, ...) either keep them
alive in class members (hence create them only once); or create them inside the Paint
handler and don't forget to call Dispose() on them.


Smile | :)

Luc Pattyn [Forum Guidelines] [My Articles]

- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets


GeneralRe: Graphs disappear from panel Pin
StuffyEst5-Mar-09 12:26
StuffyEst5-Mar-09 12:26 
AnswerRe: Graphs disappear from panel Pin
S K Y5-Mar-09 13:54
S K Y5-Mar-09 13:54 
GeneralRe: Graphs disappear from panel Pin
StuffyEst10-Mar-09 0:38
StuffyEst10-Mar-09 0:38 
QuestionEvent Question Pin
E_Gold5-Mar-09 9:31
E_Gold5-Mar-09 9:31 
AnswerRe: Event Question Pin
Christian Graus5-Mar-09 9:45
protectorChristian Graus5-Mar-09 9:45 
AnswerRe: Event Question Pin
Eslam Afifi5-Mar-09 9:48
Eslam Afifi5-Mar-09 9:48 
GeneralRe: Event Question Pin
Yusuf5-Mar-09 10:11
Yusuf5-Mar-09 10:11 
GeneralRe: Event Question Pin
Eslam Afifi5-Mar-09 12:55
Eslam Afifi5-Mar-09 12:55 
GeneralRe: Event Question Pin
E_Gold5-Mar-09 10:12
E_Gold5-Mar-09 10:12 
GeneralRe: Event Question Pin
Yusuf5-Mar-09 10:22
Yusuf5-Mar-09 10:22 
AnswerRe: Event Question Pin
DaveyM695-Mar-09 10:21
professionalDaveyM695-Mar-09 10:21 
GeneralRe: Event Question Pin
E_Gold5-Mar-09 10:31
E_Gold5-Mar-09 10:31 
GeneralRe: Event Question Pin
Christian Graus5-Mar-09 12:43
protectorChristian Graus5-Mar-09 12:43 
GeneralRe: Event Question Pin
_Maxxx_5-Mar-09 14:09
professional_Maxxx_5-Mar-09 14:09 
GeneralRe: Event Question Pin
DaveyM696-Mar-09 1:03
professionalDaveyM696-Mar-09 1:03 
GeneralRe: Event Question Pin
E_Gold7-Mar-09 19:16
E_Gold7-Mar-09 19:16 
Question2 way Remoting from client to installed service and Access Denied issue Pin
carbon_golem5-Mar-09 7:16
carbon_golem5-Mar-09 7:16 

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.