从另一个表单更改表单不透明度

编程入门 行业动态 更新时间:2024-10-10 13:16:15
本文介绍了从另一个表单更改表单不透明度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有三种形式的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。 见这里:msdn.microsoft/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: msdn.microsoft/en-us/library/ms172877.aspx[^]

更多推荐

从另一个表单更改表单不透明度

本文发布于:2023-11-02 10:01:04,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1552082.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:明度   表单   不透

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!