0

I have a problem. Im working with a picturebox and a combobox. I have an image on a picturebox and then i create graphics over a picturebox depends on the combobox item selected. When the selected combobox item change needs to clear the graphics of the picturebox but the image need to still there and create a diferent graphics.

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by Santi10_figo
0

You should save the default image of the picturebox and then use that image every time you draw graphics. I mean like this:

// Class-level variables
Image defaultImage, gImage;

public Form1()
{
    InitializeComponent();
   
    defaultImage = pictureBox.Image;
}

private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
    // This will use the picturebox's default image which has no graphics
    gImage = (Image)defaultImage.Clone();

    Graphics g = Graphics.FromImage(gImage);
    // ............
    // ............

    pictureBox.Image = gImage;
}

Hope that helps.

Thanks

0

Thanks for your fast reply. L already checked and Its exactly that I need. 1000 thanks

Be happy

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.