473,394 Members | 1,737 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,394 software developers and data experts.

PictureBox and repaint event

Hello
i have PictureBox p1:
p1.Paint += new PaintEventHandler(MyFunction);
....
public void MyFunction(Object Sender, PaintEventArgs e)

and it works fine but: when i call:
p1.Refresh();

MyFunction() ADDS everything to my picture, and i want to
repaint it from the begining. How can i do it ?

Thanx
Michal

Nov 16 '05 #1
2 1015
Jax
If you want to actually modify the the image using the gdi try this

Bitmap b = Bitmap.FromFile(somepath)
Graphics g = Graphics.FromBitmap(b)
Then if you paint using the graphics object you actually paint to the bitmap which you can the attach to the image property of the picture box

If you want further info check out this awesome FAQ:

(watch the line wrap

http://www.dotnet247.com/247referenc...diplus_faq.htm
Nov 16 '05 #2
I'm not 100% certain, but I think you want to use the Invalidate() method of
your PictureBox.
<us**@domain.invalid> wrote in message
news:e8**************@tk2msftngp13.phx.gbl...
Hello
i have PictureBox p1:
p1.Paint += new PaintEventHandler(MyFunction);
...
public void MyFunction(Object Sender, PaintEventArgs e)

and it works fine but: when i call:
p1.Refresh();

MyFunction() ADDS everything to my picture, and i want to
repaint it from the begining. How can i do it ?

Thanx
Michal

Nov 16 '05 #3

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

Similar topics

11
by: Ike | last post by:
I changing the size of frames dynamically in a page (I am restricted in that I cannot perform a reload of the content of any of the frames). In MSIE, when I resize the frames, thinks repaint...
2
by: user | last post by:
Hello i have PictureBox p1: p1.Paint += new PaintEventHandler(MyFunction); .... public void MyFunction(Object Sender, PaintEventArgs e) and it works fine but: when i call: p1.Refresh(); ...
4
by: Tim Bücker | last post by:
Hello. I want to paint some geometric shapes on the graphic context from a picture box. This picture box has dock style set to fill and is filling out the whole form. The form is maximized. This...
3
by: Tyson Ackland | last post by:
Can someone tell me how you go about handling events where your window might be obscured and then when you bring it to the foreground, you want your picturebox control to be repainted instead of...
3
by: Tom | last post by:
I have a picturebox on my VB.NET form. The picturebox size mode is set to stretched. I then load an image into that form and display it. As the user moves the mouse over the form, I want to get and...
2
by: Mattbooty | last post by:
Hello, Not sure if anyone else has seen this bug, but I have a form where the entire form is covered with a picturebox. The picturebox has a mouseup event. I also have an open file dialog for...
2
by: Joe | last post by:
I have a PictureBox that we're using like a button. Is there a way to apply a sort of highlighting to the image in the MouseEnter event? I was thinking something like changing the color of all...
4
by: fripper | last post by:
I am a real novice when it comes to the graphics class in VB 2005. I have a windows app with a large picture box control with a black background ... except for a small rectangle that has an image...
4
by: kimiraikkonen | last post by:
Hi, On my system which is 2.4GHZ P4 CPU, 1GB memory + 64MB DDR graphic card, if i create a simple picturebox docked on a form sized about 500x350 or less or more, doesn't matter, and also if i...
0
by: milkay | last post by:
<I have code that uses 2 images> the program creates a window and then when u press play, it removes all components in the container. then, i add a NewPanel object. i add mouse listeners and all...
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: 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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.