如何使用组合框将图片加载到Picturebox中 [英] how to load picture into Picturebox using combobox

查看:158
本文介绍了如何使用组合框将图片加载到Picturebox中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hai,任何人都可以建议我如何更正我的代码.似乎没有错误,但只能加载1张图片.在我的代码中,我正在使用combobox将图片加载到Picturebox中.我在组合框中有3个项目,在图片框中需要加载3个图像.有什么建议吗?


Hai , anyone can advice my how to correct my code.It seem dont have error but it only able to load 1 picture only.In my code here i am using combobox to load a image into Picturebox. I got 3 item in combo box and 3 image which need to load in picturebox.. Any suggestion?


Private Sub CBpayment_SelectedIndexChanged(ByVal sender As ystem.Object, ByVal e As System.EventArgs) Handles CBpayment.SelectedIndexChanged
   PBOffice2.Image = My.Resources.dollar_us
   PBOffice2.Image = My.Resources.check_money
   PBOffice2.Image = My.Resources.pound
End Sub

推荐答案

您的代码将在PictureBox控件中依次加载每个资源图像.但是,图片框控件一次只能显示一个图像.每次设置PictureBox.Image属性时,都将删除上一张图像,并用另一张图像替换.

如果需要同时显示多个图像,则可以使用Graphics.DrawImage在窗体上绘制它们,或者可以创建具有多个PictureBox控件的自定义控件.我建议您简单地在表单上绘制图像.
Your code would load each resource image sequentially in the PictureBox control. However, a picture box control can only display one image at a time. Each time you set the PictureBox.Image property, you''re removing the previous image and replacing it with another.

If you need to display multiple images simultaneously, you could instead draw them on your form using Graphics.DrawImage, or you could create a custom control with multiple PictureBox controls. I would suggest simply drawing the images on the form.


这篇关于如何使用组合框将图片加载到Picturebox中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆