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.

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

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

Be happy

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.