c#中的menuStrip1和主窗体中的图像 [英] menuStrip1 in c# and image in main form

查看:220
本文介绍了c#中的menuStrip1和主窗体中的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

只需使用菜单条和表格进行测试。



第1步:登录屏幕



第2步:登录后,可以在中心放置一个图像,在顶部放置菜单条。



步骤3:点击菜单条中的任何一个链接,一个新的表格打开。



第4步:现在关闭表格,你回到主屏幕,但没有图像。



现在的问题是如何将该图像带回主屏幕。

Just doing a test with menu Strip and form.

step 1: Login screen

step 2: after login one can c an Image in centre and menu Strip on top.

step 3: click on any one of the link from menu Strip, a new form opens.

step 4: now close the form, and u are back to main screen, BUT WITH NO IMAGE.

Now problem is how to bring that image back on main screen.

推荐答案

我们无法真正回答这个问题 - 只是没有足够的信息。您可以通过任意数量的方法显示图像,但最可能的问题是您将图像直接绘制到表单上,而不是作为Paint事件的一部分。例如,一旦Login完成,您可能正在获取表单的Graphics上下文并使用DrawImage绘制图片。这是有效的,但它不是持久的 - 只要表单需要重新绘制(就像当另一个表单或应用程序超过它的时候那样)它就会消失,因为DrawImage方法不是自动调用的时间。



你可以做几件事:

1)将你的图片绘画移动到表格的Paint事件处理程序,并使用提供的Graphics上下文。

2)将图像设置为Form.BackgroundImage属性,让它全部排序。



如果这不是问题,那么我们需要更好的信息! :笑:
We can't really answer this absolutely - there just isn't enough information there. You could be displaying the image by any number of methods, but the most likely problem is that you are painting the image directly onto the form, but not as part of the Paint event. For example, once Login is complete, you are probably getting a Graphics context for the form and using DrawImage to paint the picture. This works, but it isn't persistent - as soon as the form needs to be re-painted (as it does when another form or application goes over the top of it) it will vanish, because the DrawImage method is not called automatically this time.

There are a couple of things you could do:
1) Move your image painting into the Paint event handler for the form, and use the Graphics context provided.
2) Set the image as the Form.BackgroundImage property and let it sort it all out.

If this isn't the problem, then we need better information! :laugh:


当你打开新表格时使用此代码

When you open New Form Use This Code
Form1 fm =New Form1();
fm.ShowDailog(This);


这篇关于c#中的menuStrip1和主窗体中的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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