Thanks Greg, this is the code I got some of this from a project I
founded in Internet, when I use the DrawToScale function or I try to set
the Image ( both are commented out ) I get the same error " invalid
argument " ????
I was not able to find any wrong argument in the code, but I'm new to C#
so please help me out
)
Thanks,
Paolo L.
---------------------
private void dataGrid1_Click(object sender, System.EventArgs e)
{
try
{
iIDListview =
System.Convert.ToInt32(this.dataGrid1[dataGrid1.CurrentRowIndex,0].ToString(
));
string sString = this.dataGrid1[dataGrid1.CurrentRowIndex,1].ToString();
//this.oleDbDataAdapter2.Fill(this.dsImmage11);
this.oleDbConnection1.Open();
this.oleDbDataAdapter2.SelectCommand.Parameters[0].Value=sString.Trim();
byte[] bB = (byte[])
this.oleDbDataAdapter2.SelectCommand.ExecuteScalar();
if (bB.Length > 0 )
{
System.IO.MemoryStream Stream1 = new System.IO.MemoryStream(bB,true);
Stream1.Write(bB,78,bB.Length-78 );
//
//pictureBox1.Image = Image.FromStream(Stream1,true);
//DrawToScale(Image.FromStream(Stream1,false));
//
Stream1.Close();
}//if*/
// caricamento dettagli
this.oleDbDataAdapter3.SelectCommand.Parameters[0].Value= iIDListview;
this.oleDbDataAdapter3.Fill(this.dsDetail1);
this.oleDbDataAdapter4.SelectCommand.Parameters[0].Value= iIDListview;
this.oleDbDataAdapter4.Fill(this.dsDetLoc1);
this.oleDbDataAdapter5.SelectCommand.Parameters[0].Value= iIDListview;
this.oleDbDataAdapter5.Fill(this.dsDetMove1);
//
}
catch (Exception eE)
{
MessageBox.Show(eE.Message);
}
finally
{
this.oleDbConnection1.Close();
}
}
private void DrawToScale(Image bmp)
{
// The client rectangle
Rectangle rc = pictureBox1.ClientRectangle;
// From Programming Windows with C#, by Charles Petzold
// Figure out the scaling necessary for the image
SizeF size = new SizeF( bmp.Width / bmp.HorizontalResolution,
bmp.Height / bmp.VerticalResolution);
float fScale = Math.Min( rc.Width / size.Width, rc.Height / size.Height);
size.Width *= fScale;
size.Height *= fScale;
// Create a new bitmap of the proper size for the existing bitmap
// and assign it to the picture box
pictureBox1.Image = new Bitmap(bmp, size.ToSize());
}
---------------------
Paolol, we really need to know what the error is to be able to help. How
about posting the complete text and the code that caused it.