Hi,
In order for your graphic to display you need to create an event handler for the PictureBox Paint event and use the Graphics objet g to draw.
Here is an example : -
private void PB1_Paint(object sender, PaintEventArgs e)
{
Rectangle rect = new Rectangle(10, 10, 100, 200);
LinearGradientBrush GBrush = new System.Drawing.Drawing2D.L
Font BrushFont = new Font("Times New Roman", 24);
e.Graphics.DrawString("Loo
}
When the Form loads this paint event is called to paint the PictureBox, hence the string is displayed.
As for saving your GDI+ graphic to a file, well, thats a bit more involved. Have a look at the following example :-
http://www.vbdotnetheaven.
In this example, the whole screen is "bit blasted" to a bitmap in memory, which is then saved to file. You can modify the example to "bit blast" a selected area of the screen (i.e. your PictureBox).
Hope this helps.
Main Topics
Browse All Topics





by: eternal_21Posted on 2005-07-21 at 14:41:31ID: 14497864
Create an event handler for your PictureBox's Paint event, and draw on the graphics obeject there:
private void PB1_Paint(object sender, PaintEventArgs e)
{
Graphics g = e.Graphics;
//...
}