从另一个表单更改表单不透明度 [英] Change form Opacity from another form

查看:98
本文介绍了从另一个表单更改表单不透明度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有三种形式的backgroundform,form1和form2

backgroundform是启动形式。两种形式都在背景下运行



我在form1中添加了一个按钮来运行form2 ..
按钮上的
我有代码



I have three forms backgroundform, form1 and form2
backgroundform is startup form. Both forms run under backgroundform

I have add one button in form1 to run form2..
on button i have code

me.opacity = 0.5
form2.show()



和form2中有一些代码关闭按钮


and in form2 have some code on close button

me.close()
form1.opacity = 1



当我运行我的项目时它不起作用...当form2启动时,form1不透明度改变但是

当form2关闭时,form1保持相同的状态....



但是我希望当form2关闭然后form1不透明度改变0.5到1

但它不起作用..



如果我尝试:


when I run my project it does not work...when form2 starts, form1 opacity changed but
when form2 close, form1 remain same state....

But I want when form2 close then form1 opacity change 0.5 to 1
but it is not working..

if I try to:

form1.show()

然后它显示一个新的form1,其中不具有不透明度0.5 ....

请帮助.....

then it show a new form1 not which has opacity 0.5....
please help.....

推荐答案

更改opaci表单中的ty,不是以不同的形式。



最好的方法是在form2中创建一个事件,该事件以创建form2实例的形式处理 - 然后,当需要更改不透明度时,form2会发出事件信号。然后处理程序指示form1实例更改,或者更改它本身就是form1。



见这里:http://msdn.microsoft.com/en-us/library/ms172877.aspx [ ^ ]
Change the opacity in the form itself, not in a different form.

The best way is to create an event in form2 which is handled in the form that creates the form2 instance - the form2 then signals the event when it wants the opacity changed. The handler then either instructs the form1 instance to change, or changes it itself it is is form1.

See here: http://msdn.microsoft.com/en-us/library/ms172877.aspx[^]


这篇关于从另一个表单更改表单不透明度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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