Click here to Skip to main content
15,896,348 members
Home / Discussions / C#
   

C#

 
GeneralRe: How to represent this type of data in a c# app? Pin
stephen.darling12-Sep-10 16:10
stephen.darling12-Sep-10 16:10 
GeneralRe: How to represent this type of data in a c# app? Pin
PIEBALDconsult12-Sep-10 16:22
mvePIEBALDconsult12-Sep-10 16:22 
QuestionTaking screenshots of PCs on LAN Pin
teknolog12312-Sep-10 8:50
teknolog12312-Sep-10 8:50 
AnswerRe: Taking screenshots of PCs on LAN Pin
OriginalGriff12-Sep-10 9:23
mveOriginalGriff12-Sep-10 9:23 
GeneralRe: Taking screenshots of PCs on LAN Pin
teknolog12312-Sep-10 9:29
teknolog12312-Sep-10 9:29 
GeneralRe: Taking screenshots of PCs on LAN Pin
OriginalGriff12-Sep-10 9:43
mveOriginalGriff12-Sep-10 9:43 
GeneralRe: Taking screenshots of PCs on LAN Pin
Eddy Vluggen12-Sep-10 9:53
professionalEddy Vluggen12-Sep-10 9:53 
AnswerRe: Taking screenshots of PCs on LAN Pin
Luc Pattyn12-Sep-10 9:53
sitebuilderLuc Pattyn12-Sep-10 9:53 
GeneralRe: Taking screenshots of PCs on LAN Pin
teknolog12312-Sep-10 10:04
teknolog12312-Sep-10 10:04 
GeneralRe: Taking screenshots of PCs on LAN Pin
Luc Pattyn12-Sep-10 10:12
sitebuilderLuc Pattyn12-Sep-10 10:12 
GeneralRe: Taking screenshots of PCs on LAN Pin
teknolog12312-Sep-10 10:15
teknolog12312-Sep-10 10:15 
GeneralRe: Taking screenshots of PCs on LAN Pin
Luc Pattyn12-Sep-10 10:18
sitebuilderLuc Pattyn12-Sep-10 10:18 
QuestionPainting on transparent background multiple times Pin
fdsfsa76f7sa612-Sep-10 1:47
fdsfsa76f7sa612-Sep-10 1:47 
AnswerRe: Painting on transparent background multiple times Pin
Abhishek Sur12-Sep-10 2:39
professionalAbhishek Sur12-Sep-10 2:39 
GeneralRe: Painting on transparent background multiple times Pin
fdsfsa76f7sa612-Sep-10 3:06
fdsfsa76f7sa612-Sep-10 3:06 
GeneralRe: Painting on transparent background multiple times Pin
Dave Kreskowiak12-Sep-10 5:13
mveDave Kreskowiak12-Sep-10 5:13 
GeneralRe: Painting on transparent background multiple times Pin
fdsfsa76f7sa612-Sep-10 8:49
fdsfsa76f7sa612-Sep-10 8:49 
AnswerRe: Painting on transparent background multiple times Pin
Luc Pattyn12-Sep-10 9:39
sitebuilderLuc Pattyn12-Sep-10 9:39 
GeneralRe: Painting on transparent background multiple times Pin
fdsfsa76f7sa612-Sep-10 10:50
fdsfsa76f7sa612-Sep-10 10:50 
GeneralRe: Painting on transparent background multiple times Pin
Luc Pattyn12-Sep-10 10:56
sitebuilderLuc Pattyn12-Sep-10 10:56 
Questionhow to call onPaint from Timer Pin
bimbambumbum11-Sep-10 19:13
bimbambumbum11-Sep-10 19:13 
Hi
I'm trying to work my way into the world of .NET programming so this question might be a no-brainer.


I'm trying to make a timer-control redrawing GDI graphics so that the GUI gets updated at regular time intervals.

The overrided OnPaint() is currently doing the drawing and it should be called from the timer_tick() method. Please take a look at the code below.

I looked for an onPaint() redraw/update method but couldn't find such one.

Can someone please give me a hint?

Thanks
Tom

public partial class Form1 : Form
 {
     Timer timer = new Timer();
     Graphics g;
     int x2 = 100;   // the end  location of the line being drawn
     int y2 = 100;   // the end  location of the line being drawn

     public Form1()
     {
         InitializeComponent();

         timer.Tick += new EventHandler(timer_tick);
         timer.Interval = 1000;      // update graphics every sec!!
         timer.Enabled = true;
         timer.Start();

     }

     void timer_tick(object sender, EventArgs e)
     {
         //MessageBox.Show("Tick");                    // Alert the user
     }

     private void Form1_Paint(object sender, PaintEventArgs e)
     {
     }

     protected override void OnPaint(PaintEventArgs pe)
     {
         g = pe.Graphics;

         // Draw coordinate system
         Pen pn = new Pen(Color.Black, 1);
         Point pt1 = new Point(0, 0);
         Point pt2 = new Point(x2, y2++);
         g.DrawLine(pn, pt1, pt2);

         if (y2 > 300)
             y2 = 100;       // increment y-coordinate to see that onPaint gets called from timer

     }

AnswerRe: how to call onPaint from Timer Pin
Abhinav S11-Sep-10 19:35
Abhinav S11-Sep-10 19:35 
GeneralRe: how to call onPaint from Timer Pin
bimbambumbum11-Sep-10 19:40
bimbambumbum11-Sep-10 19:40 
GeneralRe: how to call onPaint from Timer Pin
Thomas Stockwell12-Sep-10 8:29
professionalThomas Stockwell12-Sep-10 8:29 
Questioncustom titlebar Pin
Jassim Rahma11-Sep-10 7:31
Jassim Rahma11-Sep-10 7:31 

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.