469,327 Members | 1,207 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,327 developers. It's quick & easy.

View image in picture box from file

private void Apri_Click(object sender, System.EventArgs e)
{
OpenFileDialog fileChooser=new OpenFileDialog();

//fileChooser.Filter="tiff images (*.tiff)|*.tiff";

DialogResult result = fileChooser.ShowDialog();

Image immagine = New Image(fileChooser.FileName);

PictureBox.Image = immagine;
}

where's the error?
Nov 16 '05 #1
5 19868
You have to use FromFile method....

Image immagine = Image.FromFile(fileChooser.FileName);
pictureBox1.Image = immagine;

Hope it helps,

Ludovic Soeur.
"Fabio" <Fa***@discussions.microsoft.com> a écrit dans le message de
news:51**********************************@microsof t.com...
private void Apri_Click(object sender, System.EventArgs e)
{
OpenFileDialog fileChooser=new OpenFileDialog();

//fileChooser.Filter="tiff images (*.tiff)|*.tiff";

DialogResult result = fileChooser.ShowDialog();

Image immagine = New Image(fileChooser.FileName);

PictureBox.Image = immagine;
}

where's the error?

Nov 16 '05 #2
HI Fabio,

Replace the following statement in your code

Image immagine = New Image(fileChooser.FileName);

with this.

System.Drawing.Bitmap immagine = new Bitmap(fileChooser.FileName);

You can assign only a bitmap object to the image property of the PictureBox

happy programming!!
pradeep_TP

"Fabio" wrote:
private void Apri_Click(object sender, System.EventArgs e)
{
OpenFileDialog fileChooser=new OpenFileDialog();

//fileChooser.Filter="tiff images (*.tiff)|*.tiff";

DialogResult result = fileChooser.ShowDialog();

Image immagine = New Image(fileChooser.FileName);

PictureBox.Image = immagine;
}

where's the error?

Nov 16 '05 #3
if i write this

Image immagine = Image.FromFile(fileChooser.FileName);
pictureBox1.Image = immagine;
tell me

'System.Drawing.Image' does not contain a definition for 'FromFile'

"Ludovic SOEUR" wrote:
You have to use FromFile method....

Image immagine = Image.FromFile(fileChooser.FileName);
pictureBox1.Image = immagine;

Hope it helps,

Ludovic Soeur.
"Fabio" <Fa***@discussions.microsoft.com> a écrit dans le message de
news:51**********************************@microsof t.com...
private void Apri_Click(object sender, System.EventArgs e)
{
OpenFileDialog fileChooser=new OpenFileDialog();

//fileChooser.Filter="tiff images (*.tiff)|*.tiff";

DialogResult result = fileChooser.ShowDialog();

Image immagine = New Image(fileChooser.FileName);

PictureBox.Image = immagine;
}

where's the error?


Nov 16 '05 #4
This one give me errors deployment :(

"pradeep_TP" wrote:
HI Fabio,

Replace the following statement in your code

Image immagine = New Image(fileChooser.FileName);

with this.

System.Drawing.Bitmap immagine = new Bitmap(fileChooser.FileName);

You can assign only a bitmap object to the image property of the PictureBox

happy programming!!
pradeep_TP

"Fabio" wrote:
private void Apri_Click(object sender, System.EventArgs e)
{
OpenFileDialog fileChooser=new OpenFileDialog();

//fileChooser.Filter="tiff images (*.tiff)|*.tiff";

DialogResult result = fileChooser.ShowDialog();

Image immagine = New Image(fileChooser.FileName);

PictureBox.Image = immagine;
}

where's the error?

Nov 16 '05 #5
The code that you give me are good but they don't work for my application
cause is a program for a pocket pc. Why there's a lot of problem to develop
an application for a pocket pc? How can i do to open an image for a ppc?

"Fabio" wrote:
private void Apri_Click(object sender, System.EventArgs e)
{
OpenFileDialog fileChooser=new OpenFileDialog();

//fileChooser.Filter="tiff images (*.tiff)|*.tiff";

DialogResult result = fileChooser.ShowDialog();

Image immagine = New Image(fileChooser.FileName);

PictureBox.Image = immagine;
}

where's the error?

Nov 16 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by VJ | last post: by
10 posts views Thread by Shahnaz | last post: by
4 posts views Thread by Generic Usenet Account | last post: by
14 posts views Thread by Steve K. | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by listenups61195 | last post: by
reply views Thread by Purva khokhar | last post: by
reply views Thread by haryvincent176 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.