如何在 C# 中使表单的一部分部分透明? [英] How can I make a part of the form partially transparent in C#?

查看:31
本文介绍了如何在 C# 中使表单的一部分部分透明?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将表单的一部分设为半透明,在不透明的部分添加附加文本.

I want to make a part of a form semi-transparent, with additional text on that part which is not transparent.

如何在 C# 中完成此操作?

How can I accomplish this in C#?

推荐答案

我认为您不能将透明度(更准确地说,Opacity)应用于表单的一部分而不是表单的一部分完整的完整表格.

I don't think you can apply transparency (more correctly termed, Opacity) to only a part of a form rather than the complete, whole form.

但是,您可以很容易地创建自定义形状的表单(即非矩形),该表单的各个部分都是透明的.根据您想要达到的确切外观",这可能是您最接近的.

You can, however, create a custom shaped form (i.e. non-rectangular) quite easily, with various parts of that form being transparent. Depending upon the exact "look" that you're trying to achieve, this may be closest you'll get.

查看这些链接以创建您自己的自定义形状的表单:

Take a look at these links for creating your own custom-shaped form:

在 .NET 中创建自定义形状的 Windows 窗体
C# 中带有下拉菜单的自定义形状表单
Visual Studio .NET 中的异形 Windows 窗体和控件

唯一的另一种选择可能是显示两种形式,其中一种设置为部分透明.您必须以编程方式确保第二个表单紧邻主"表单,并在用户移动/调整主"表单的大小时按比例移动/调整大小.虽然这是两种形式,但可以让用户看到它实际上只是一种形式,尽管这可能很难实现,并且不会是一个完美的解决方案(但可能足够好",具体取决于根据您的确切需求).

The only other alternative may be to display two forms, one of which is set to be partially transparent. You would have to programmatically ensure that the second form is positioned immediately next to the "main" form, and is moved/resized proportionately when the user moves/resizes the "main" form. Although this is two forms, it could be made to look, to the user, that it's actually only one form, although this could be quite tricky to pull off, and would not be a perfect solution (but may be "good enough" depending upon your exact needs).

这篇关于如何在 C# 中使表单的一部分部分透明?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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