Sunday, February 24, 2013
Button click event load Pic into picturebox
private void btnLoad_Click(object sender, EventArgs e)
{
OpenFileDialog dlg = new OpenFileDialog();
dlg.Title = "Open Photo";
dlg.Filter = "jpg files (*.jpg)|*.jpg|All files(*.*)|*.*";
if (dlg.ShowDialog() == DialogResult.OK)
{
pBoxLoad.Image = new Bitmap(dlg.OpenFile());
}
dlg.Dispose();
}
A delegate is similar to a function pointer in C or C++ except that delegates are typesafe.
The term type-safe means that code is specified in a well-defined manner that can
be recognized by a compiler. In this case, it means that an incorrect use of a delegate
is a compile-time error. This is quite different than in C++, where an incorrect use of
a function pointer may not cause an error until the program is running.
dlg.Dispose()==>
While the garbage collector frees us from worrying about memory cleanup, nonmemory
resources are still an issue. In this case, our OpenFileDialog object allocates
operating system resources to display the dialog and file system resources to
open the file via the OpenFile method. While the garbage collector may recover
these resources eventually, such resources may be limited and should always be
reclaimed manually by calling the Dispose method.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment