开发者

How to set the Image property of a PictureBox Control by using OpenFileDialog? C# winforms

开发者 https://www.devze.com 2023-02-06 07:09 出处:网络
How to set the Image property of a Pictu开发者_如何学PythonreBox Control by using OpenFileDialog?Set PictureBox.Image using Image.FromFile

How to set the Image property of a Pictu开发者_如何学PythonreBox Control by using OpenFileDialog?


Set PictureBox.Image using Image.FromFile

OpenFileDialog _openFileDialog = new OpenFileDialog();
_openFileDialog.FileOk += OpenFileDialogFileOk;
_openFileDialog.CheckFileExists = true;
_openFileDialog.CheckPathExists = true;
_openFileDialog.ShowDialog();

void OpenFileDialogFileOk(object sender, CancelEventArgs e)
{
    var imageInformation = new FileInfo(_openFileDialog.FileName);
    var sizeInBytes = imageInformation.Length;

    myPictureBox.Image = Image.FromFile(_openFileDialog.FileName);
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号