如何在其他类中访问表单控件 [英] How access form controls in another classes

查看:68
本文介绍了如何在其他类中访问表单控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿.我通过GDI +将位图图像加载到我的loaddata类中. 然后我想在主窗体中访问一个图片框以显示
位图图像.如何访问loaddata类中的图片框?

Hey.I load a bitmap image into my loaddata class by GDI+.
then i want to access a picturebox in my main form to show the
bitmap image.How can i access picture box in loaddata class?

推荐答案

最好的方法是将图像返回到函数中的表单. br/>
在您的loaddata类中,创建一个加载图像并返回图像的函数.

在表单类中,调用该函数并将图像放在图片框中.

这是最好的方法,因为您将表单与数据类分开,并将图像的加载与表单分开.

如果您需要更多详细信息,请随时在评论中寻求更详细的答案.
The best way to do that would be to return the image to the form in the function.

In your loaddata class, create a function that load the image and return it.

In your form class, call the function and put the image in the picture box.

That''s the best way to do it because you separate the form from your data class and you separate the loading of the image from your form.

If you need more detail, don''t hesitate to ask for a more detailed answer in the comments.


这篇关于如何在其他类中访问表单控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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