Click here to Skip to main content
16,008,075 members
Home / Discussions / C#
   

C#

 
GeneralRe: am a beginner and need good beginners toturials HELP ME!! Pin
Vasudevan Deepak Kumar14-Aug-05 2:36
Vasudevan Deepak Kumar14-Aug-05 2:36 
Questioncan i drow curve in c# interface Pin
malak nour12-Aug-05 7:04
malak nour12-Aug-05 7:04 
AnswerRe: can i drow curve in c# interface Pin
Judah Gabriel Himango12-Aug-05 8:46
sponsorJudah Gabriel Himango12-Aug-05 8:46 
AnswerRe: can i drow curve in c# interface Pin
[Marc]12-Aug-05 12:12
[Marc]12-Aug-05 12:12 
Generaldownloading Pin
Kimocat12-Aug-05 6:32
Kimocat12-Aug-05 6:32 
GeneralRe: downloading Pin
Alomgir Miah12-Aug-05 7:05
Alomgir Miah12-Aug-05 7:05 
GeneralRe: downloading Pin
Judah Gabriel Himango12-Aug-05 8:47
sponsorJudah Gabriel Himango12-Aug-05 8:47 
GeneralChanging the 'invalid' area from within OnPaint handler Pin
roel_12-Aug-05 6:17
roel_12-Aug-05 6:17 
Hi all,

I have a custom control, derived from System.Windows.Forms.UserControl. I'm using AutoScroll in this control to provide scrolling. I've overridden OnPaint in my control to do the drawing of the control. When the user scrolls, an Invalidate() is done on the control with the area that is newly exposed so that the invalidated area is as small as possible (this is done by the framework, not by me). Now my problem is that I want to update more of the control than just the part that is scrolled into view. I see two possibilities:
- Update the whole control when the user scrolls. Unfortunately I don't see a way to tell ScrollableControl (the class that UserControl is derived from that provides scrolling capabilities) to update the whole control when scrolling; I also don't see a way to get to the scrollbars directly to connect to a Scrolled() event (as confirmed in the windows.forms Petzold).
- Change the invalidated region from within the OnPaint handler. If I could find a way to tell the control to redraw everything and not just the rectangle that was passed to Invalidate() I could do that at the top of my OnPaint() member and be done. But no matter what I try, it seems I cannot update the invalidated area without calling Invalidate(), which will also send a WM_PAINT - I don't want since I'm already in OnPaint and that will create an infinite loop! The hack I came up with is something like this:

private bool m_DoingSecondOnPaint = false;

protected override void OnPaint(PaintEventArgs pea)
{
  if (!m_DoingSecondOnPaint) {
    m_DoingSecondOnPaint = true;
    Invalidate();
  } else {
    m_DoingSecondOnPaint = false;
  }

  ... do rest of drawing here ...
}


but as you can see this means that all the drawing code is executed twice for every time I want to draw the control. Is there a better way to do this?

cheers & thanks,

roel
GeneralAlign ColumnHeader Text Pin
zaboboa12-Aug-05 5:44
zaboboa12-Aug-05 5:44 
GeneralRe: Align ColumnHeader Text Pin
ToddHileHoffer12-Aug-05 7:18
ToddHileHoffer12-Aug-05 7:18 
GeneralRe: Align ColumnHeader Text Pin
zaboboa12-Aug-05 7:31
zaboboa12-Aug-05 7:31 
GeneralUser Control event raising Pin
Rizwan Bashir12-Aug-05 5:26
Rizwan Bashir12-Aug-05 5:26 
GeneralPictureBox properties need to help Pin
malak nour12-Aug-05 5:12
malak nour12-Aug-05 5:12 
GeneralRe: PictureBox properties need to help Pin
Libor Tinka12-Aug-05 6:39
Libor Tinka12-Aug-05 6:39 
GeneralRe: PictureBox properties need to help Pin
Kimocat12-Aug-05 6:54
Kimocat12-Aug-05 6:54 
GeneralExport from textbox to external file Pin
Code Toad12-Aug-05 4:48
Code Toad12-Aug-05 4:48 
GeneralRe: Export from textbox to external file Pin
Guffa12-Aug-05 5:47
Guffa12-Aug-05 5:47 
GeneralRe: Export from textbox to external file Pin
Code Toad12-Aug-05 9:04
Code Toad12-Aug-05 9:04 
GeneralScale and Transform Location Pin
GoodQuestion12-Aug-05 4:42
GoodQuestion12-Aug-05 4:42 
GeneralRe: Scale and Transform Location Pin
Werdna12-Aug-05 9:17
Werdna12-Aug-05 9:17 
GeneralProblem with TapControl Pin
Anonymous12-Aug-05 4:29
Anonymous12-Aug-05 4:29 
GeneralRe: Problem with TapControl Pin
mhmo13-Aug-05 7:32
mhmo13-Aug-05 7:32 
GeneralGet the value of primary key as output parameter... Pin
signbit12-Aug-05 4:25
signbit12-Aug-05 4:25 
GeneralRe: Get the value of primary key as output parameter... Pin
Guffa12-Aug-05 5:25
Guffa12-Aug-05 5:25 
GeneralUserControl interaction Pin
tehe12-Aug-05 3:53
tehe12-Aug-05 3:53 

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.