Click here to Skip to main content
15,913,296 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
AnswerRe: adding a panel to a form. Pin
bimbambumbum22-Sep-10 14:03
bimbambumbum22-Sep-10 14:03 
AnswerRe: adding a panel to a form. Pin
Luc Pattyn22-Sep-10 14:04
sitebuilderLuc Pattyn22-Sep-10 14:04 
GeneralRe: adding a panel to a form. [modified] Pin
bimbambumbum22-Sep-10 14:42
bimbambumbum22-Sep-10 14:42 
AnswerRe: adding a panel to a form. Pin
Luc Pattyn22-Sep-10 15:28
sitebuilderLuc Pattyn22-Sep-10 15:28 
GeneralRe: adding a panel to a form. Pin
bimbambumbum22-Sep-10 17:04
bimbambumbum22-Sep-10 17:04 
AnswerRe: adding a panel to a form. Pin
Luc Pattyn22-Sep-10 17:13
sitebuilderLuc Pattyn22-Sep-10 17:13 
GeneralRe: adding a panel to a form. Pin
bimbambumbum25-Sep-10 4:46
bimbambumbum25-Sep-10 4:46 
GeneralRe: adding a panel to a form. Pin
Luc Pattyn25-Sep-10 5:21
sitebuilderLuc Pattyn25-Sep-10 5:21 
Hi Tom,

1.
in your DoubleBufferPanel constructor, all you need is this.DoubleBuffered = true;
I think it is equivalent to what you have though.

2.
I'm a bit confused by your code:
this.Controls.Add(myPanel);

if that really sits inside the Paint handler you are adding a panel each time, which may result in the Panel being repainted twice, thrice, etc later on, causing unnecessary screen activity, hence flickering.

3.
I'm horified by:
myPanel.BackgroundImage = myBitmap;

What you do here is, whenever the system thinks it needs to repaint the panel you also give it a new background image, causing it to need yet another repaint. So it is probably repainting continuously.

4.
And finally I'm disappointed by:
// Copy the RGB values into the array

We already established there was absolutely no need to do that. With a circular bitmap, update "the next" column, then paint both halves at the right position.

In summary:
- create a doublebuffered panel once
- add it to your form once
- never use the BackgroundImage
- have an updateData() method that stores new pixels in one column of the bitmap (I kept a Graphics to do that)
- in your Paint handler, have only two statements, both e.Graphics.DrawImage() with the correct parameters.

Warning: you cannot keep LockBits open forever as DrawImage would then fail, so if you use LockBits, you must call UnlockBits at the end of the column update, otherwise you can't have it painted. You can keep a Graphics open on the bitmap though.

Smile | :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.


GeneralRe: adding a panel to a form. [modified] Pin
bimbambumbum25-Sep-10 5:31
bimbambumbum25-Sep-10 5:31 
GeneralRe: adding a panel to a form. Pin
Luc Pattyn25-Sep-10 6:08
sitebuilderLuc Pattyn25-Sep-10 6:08 
GeneralRe: adding a panel to a form. [modified] Pin
bimbambumbum25-Sep-10 11:20
bimbambumbum25-Sep-10 11:20 
GeneralRe: adding a panel to a form. Pin
Luc Pattyn25-Sep-10 12:02
sitebuilderLuc Pattyn25-Sep-10 12:02 
QuestionsqlDataAdapter doest not refresh the query Pin
akosidandan22-Sep-10 5:20
akosidandan22-Sep-10 5:20 
AnswerRe: sqlDataAdapter doest not refresh the query Pin
Not Active22-Sep-10 7:42
mentorNot Active22-Sep-10 7:42 
GeneralRe: sqlDataAdapter doest not refresh the query Pin
akosidandan22-Sep-10 22:40
akosidandan22-Sep-10 22:40 
GeneralRe: sqlDataAdapter doest not refresh the query Pin
Not Active23-Sep-10 1:08
mentorNot Active23-Sep-10 1:08 
QuestionHow to Show Specific Records in listview Pin
akosidandan22-Sep-10 1:38
akosidandan22-Sep-10 1:38 
AnswerRe: How to Show Specific Records in listview Pin
Luc Pattyn22-Sep-10 2:23
sitebuilderLuc Pattyn22-Sep-10 2:23 
GeneralRe: How to Show Specific Records in listview Pin
akosidandan22-Sep-10 2:29
akosidandan22-Sep-10 2:29 
GeneralRe: How to Show Specific Records in listview Pin
Luc Pattyn22-Sep-10 2:47
sitebuilderLuc Pattyn22-Sep-10 2:47 
QuestionFile recovery Pin
hammerstein0522-Sep-10 0:57
hammerstein0522-Sep-10 0:57 
AnswerRe: File recovery Pin
Pete O'Hanlon22-Sep-10 1:37
mvePete O'Hanlon22-Sep-10 1:37 
GeneralMessage Removed Pin
22-Sep-10 4:23
molesworth22-Sep-10 4:23 
GeneralRe: File recovery Pin
Pete O'Hanlon22-Sep-10 4:35
mvePete O'Hanlon22-Sep-10 4:35 
GeneralRe: File recovery [modified] Pin
molesworth22-Sep-10 4:38
molesworth22-Sep-10 4:38 

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.