473,378 Members | 1,427 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Redrawing a part of a control

Hi all,

I am drawing some lines on a picturebox control. In the .Paint event
of the picturebox I draw the lines of a graph. These lines are static
and never move. Now, in the same Sub I am drawing the plot of the
graph based on some changing variables in memory.

This works and when the variables change in memory I call the
Invalidate method of the picturebox to redraw the lines. This seems
wrong to me as I am drawing many lines again (the graph axis etc.) just
to refresh the line of the graph. It also gives me a flicker.

Does anyone know of a better way to eliminate the existing line on the
graph and redraw it (or to redraw an existing line if that is
possible.)

Thanks,
Hugh

Aug 18 '06 #1
2 1362
Create a bitmap
Dim bmp as BitMap(Width,Height)
Dim g as graphics = graphics.fromimage(bmp) - please check , not at regular
computer.
with g
..draw etc
..dispose()
end with
backgroundimage = bmp

now you can refresh and draw temp lines etc.
Aug 18 '06 #2
Hello Hugh,

Set double buffering on (See the SetStyle method).. this will help to eliminate
the flicker. Also set all painting to be done in the WM_PAINT (same method).
Also, since the grid lines don't change (but I assume they are generated
dynamicly).. you could draw them into a bitmap that you hold in memory..
then when it's time to redraw the graph, blit the bitmap onto the canvas
and then redraw your value lines. Since this is raster stuff and not vector
there's really no way of saying.. erase this one line only and redraw it.
Even behind the scenes vector rendering is really raster.. same principles
apply there.
Hi all,

I am drawing some lines on a picturebox control. In the .Paint event
of the picturebox I draw the lines of a graph. These lines are static
and never move. Now, in the same Sub I am drawing the plot of the
graph based on some changing variables in memory.

This works and when the variables change in memory I call the
Invalidate method of the picturebox to redraw the lines. This seems
wrong to me as I am drawing many lines again (the graph axis etc.)
just to refresh the line of the graph. It also gives me a flicker.

Does anyone know of a better way to eliminate the existing line on the
graph and redraw it (or to redraw an existing line if that is
possible.)

Thanks,
Hugh

Aug 19 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Otie | last post by:
I have a circle that displays information in 1-degree increments - there are 90 such increments that comprise the circle. I need a pointer within the circle that rotates. The pointer must include...
1
by: Marco Terzuoli | last post by:
Hi, I am making a program which has got some GUI. I need a timer in it which performs some kind of operations. What I am doing now is something like while 1: sleep(1) do_stuff() But this...
5
by: Michel | last post by:
How to force the redrawing of a Form?
7
by: Dino Buljubasic | last post by:
Hi, I am using C# 2.0 (VS2005) to build my user control that contains a number of dynamically loaded ListViews. ListViewItems have their ForeColor properties set to either black or blue to...
4
by: Sugan | last post by:
Hi all, I've created a Custom button control and i'm drawing the graphics for the button when the paint event is fired. I used Invalidate method to redraw the graphics in events like mousemove,...
0
by: Jose Walker | last post by:
Hi there! I've been fighting with an issue that by now is driving me crazy. I've developed a ASP.NET 2 web part from which I build dynamically an ASP.NET 2 Menu control, I populate the control...
4
by: Adam Clauss | last post by:
I have a completely user-drawn user control in which I enabled transparency (follownig suggestions at...
5
by: Ryan | last post by:
Hello everyone, What is the best way to cache a 2.0 web part? I tried putting output cache on the user control in the part, but the output cache cannot be wrapped by a generic web part . . ....
1
by: NCC | last post by:
Hi all, In Access VB I could call echo() to stop my form from redrawing during computations then have it redraw upon completion. Is there a method for this in Visual C# or the .net framework.? ...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.