Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
335
Setting UltraPictureBox image with code
posted

I'm trying to set the image of an UltraPictureBox dynamically through code when I click on a buttton but it won't show the image.  Is there something I am forgetting?  I have tried update, refresh, etc...

Thanks.

  • 37774
    Verified Answer
    posted

    How are you setting the image?  Are you sure that the image is actually being loaded?  Does this work with the .NET PictureBox?  I just tried this out through a button click and didn't really have any trouble; as a simplified test, I created the image in code:

    private void button1_Click(object sender, EventArgs e)
    {
        Bitmap bmp = new Bitmap(300, 300);
        using (Graphics g = Graphics.FromImage(bmp))
        {
            g.FillRectangle(Brushes.Red, new Rectangle(Point.Empty, bmp.Size));
        }
        this.ultraPictureBox1.Image = bmp;
    }

    -Matt