列表框语法上的 WinForms MouseEventHandler
我有一个文件列表,当我单击每个文件时,我希望它显示图像的预览。 我想我已经编写了代码,但我不确定 () 中的内容
this.listBox1.MouseUp += new System.Windows.Forms.MouseEventHandler();
我希望单击来执行此操作
private void listBox1_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
// get selected filename
string curItem = listBox1.SelectedItem.ToString();
// BitmapImage.UriSource must be in a BeginInit/EndInit block
BitmapImage myBitmapImage = new BitmapImage();
myBitmapImage.BeginInit();
myBitmapImage.UriSource = new Uri(@curItem);
myBitmapImage.DecodePixelWidth = 200;
myBitmapImage.EndInit();
uploadImage.Source = myBitmapImage;
}
I have a list of files and when I click on each one I want it to display a preview of the image.
I think I have the write code but I'm not sure what goes in the ()
this.listBox1.MouseUp += new System.Windows.Forms.MouseEventHandler();
I want the click to do this
private void listBox1_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
// get selected filename
string curItem = listBox1.SelectedItem.ToString();
// BitmapImage.UriSource must be in a BeginInit/EndInit block
BitmapImage myBitmapImage = new BitmapImage();
myBitmapImage.BeginInit();
myBitmapImage.UriSource = new Uri(@curItem);
myBitmapImage.DecodePixelWidth = 200;
myBitmapImage.EndInit();
uploadImage.Source = myBitmapImage;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我差得很远。这有效。
I was way off. This works.