Visual Studio .NET - HELP!!! Adding a bitmap to a panel?

Asked By Jason Hardesty on 04-Nov-08 07:55 AM

I was wonder if I created a bitmap if I could add it to a Panel? For example:

Panel panel = new panel()

panel.Width = 10;

panel.Height = 10;

Bitmap bitmap = new Bitmap(10, 10);

Graphics g = Graphics.FromImage(bitmap);

g.FillRectangle(Brushes.Black, 0, 0, 10, 10);

//Some how add bitmap to Panel 

//I know this isn't correct

panel.Image = bitmap;

I am creating a graph library( already did in C# for windows forms) and want a panel for the graph and then panels within the graph panel for the x and y axis and for where the points will be displayed. This is how I did it in C# so was hoping I could do the same thing. Thanks for any help!

HELP!!! Adding a bitmap to a panel?

Jignesh Shah replied to Jason Hardesty on 04-Nov-08 08:00 AM

you have two choices:

1.  add Image Objects to Panel : http://www.eggheadcafe.com/software/aspnet/33025250/adding-image-objects-to-p.aspx

2. Use picturebox : see http://forums.devarticles.com/net-development-43/c--drawing-an-image-on-a-panel-8052.html

try your same code

Jignesh Shah replied to Jason Hardesty on 04-Nov-08 08:01 AM
try your same code with "panel.Controls.Add( bitmap);" instead of  panel.Image = bitmap;

Try this:

Binny ch replied to Jason Hardesty on 04-Nov-08 11:26 AM

If the image is stored in default project folder.

<asp:Panel ID="Panel1" runat="server" Height="100px" Style="z-index: 106; left: 123px;
            position: absolute; top: 7px" Width="735px" BackImageUrl="App_Data/logo1.bmp">
        </asp:Panel>

convert that bmp to jpg to save time on load

ADDING A BITMAP TO A PANEL
C_A P replied to Jason Hardesty on 05-Nov-08 03:24 AM
http://msdn.microsoft.com/en-us/library/aa478960.aspx
http://www.daniweb.com/forums/thread105207.html