@@@@@@在半透明的form上如何让button等控件不透明!!!

cyfboy 2006-07-27 03:39:53
用 this.Opacity = 0.4; 让form 半透明
可是上面的控件 button picturebox 也都半透明了
如何让这些控件不透明?
...全文
296 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
cyfboy 2006-08-03
  • 打赏
  • 举报
回复
To oolongTea(乌龙茶)
你给的是镂空效果,我的意思是要求在一个“半透明”的容器中,显示button控件(不透明),该如何办呢?
tonysunny 2006-08-03
  • 打赏
  • 举报
回复
楼上的方法很特别,呵呵
oolongTea 2006-08-03
  • 打赏
  • 举报
回复
这种效果如何:

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace WindowsApplication10
{
/// <summary>
/// Form1 的摘要说明。
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Panel panel1;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;

public Form1()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();

//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
}

/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
this.panel1 = new System.Windows.Forms.Panel();
this.panel1.SuspendLayout();
this.SuspendLayout();
//
// button1
//
this.button1.BackColor = System.Drawing.SystemColors.Control;
this.button1.Location = new System.Drawing.Point(72, 80);
this.button1.Name = "button1";
this.button1.TabIndex = 0;
this.button1.Text = "button1";
//
// panel1
//
this.panel1.BackColor = System.Drawing.Color.White;
this.panel1.Controls.Add(this.button1);
this.panel1.Location = new System.Drawing.Point(32, 48);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(232, 176);
this.panel1.TabIndex = 1;
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.BackColor = System.Drawing.SystemColors.Control;
this.ClientSize = new System.Drawing.Size(292, 273);
this.Controls.Add(this.panel1);
this.Name = "Form1";
this.Text = "Form1";
this.TransparencyKey = System.Drawing.Color.White;
this.panel1.ResumeLayout(false);
this.ResumeLayout(false);

}
#endregion

/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
}
}
xlshen_lxz 2006-08-02
  • 打赏
  • 举报
回复
写个CSS,在控件上调用这个CSS
Mittermeyer 2006-08-02
  • 打赏
  • 举报
回复
this.Opacity是通过Windows的Layed Window的风格实现半透明的,恐怕没办法让这个容器中的某个控件不透明。
非要实现这样的效果的话,只有写一个Form模拟Button的操作了。
frankccm 2006-08-01
  • 打赏
  • 举报
回复
mark
cyfboy 2006-08-01
  • 打赏
  • 举报
回复
Knight94 2006-07-28
  • 打赏
  • 举报
回复
to 用 this.Opacity = 0.4; 让form 半透明

替换这个半透明方法。
yuzhlhua 2006-07-28
  • 打赏
  • 举报
回复
真的没想到解决的办法~ mark
penda80 2006-07-28
  • 打赏
  • 举报
回复
mark
jacobwc 2006-07-28
  • 打赏
  • 举报
回复
mark mark
guojh021 2006-07-28
  • 打赏
  • 举报
回复
MARK 一下
tonysunny 2006-07-28
  • 打赏
  • 举报
回复
这个问题我也在考虑,MARK

110,571

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧