0

right, I have a visual C# app in VS2003 and am trying to load and display and image on my form. I have the following code - there are no errors, however neither does anything appear. (image exists in that directory, yes - I've had to insert the "\\" cause otherwise it would complain about the unrecognized character scape sequence thingy)

private void Form1_Load(object sender, EventArgs e)
        {
            InitializeComponent();
            Bitmap objBitmap = new Bitmap("D:\\ImageRecognition\\image.jpg");
            Graphics g = Graphics.FromHwnd(Handle);
            g.DrawImage(objBitmap, 0, 0);

        }

please help!

2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by __avd
1

>however neither does anything appear.

Place your code inside the Paint event handler of a form.

private void Form1_Paint(object sender, PaintEventArgs e)
        {
            Bitmap bmp = new Bitmap(@"c:\folder\file1.gif");
            Graphics g = Graphics.FromHwnd(this.Handle);
            g.DrawImage(bmp, 10, 10);
        }
This topic has been dead for over six months. 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.