By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,236 Members | 1,795 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,236 IT Pros & Developers. It's quick & easy.

CodeDOM graph statement for pictureBox1.Image = <Convert the binary value of the

P: 2
How can I create a CodeDOM statement to accomplish the following

this.pictureBox.Image = <Convert the binary value of the picture from the XML file and display>

I have tried the following without any success......

MemoryStream ms = new MemoryStream(Convert.FromBase64String((String)Cont rolPropertyTable["Image"]));

//Load the image from the stream.

Bitmap bmp = Bitmap.FromStream(ms) as Bitmap;

////// Assign PictureBox1.Image = <Binary value of the image>

InitializeMethod.Statements.Add(new CodeAssignStatement(new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), "pictureBox1.Image"), new CodeObjectCreateExpression(new CodeTypeReference(typeof(System.Drawing.Bitmap)), new CodeExpression[] {new CodePrimitiveExpression(ms) })));
Jan 17 '10 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.