如何在vb.net中将按钮更改为透明? [英] How to change button as transparent in vb.net ?

查看:468
本文介绍了如何在vb.net中将按钮更改为透明?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发Windows应用程序,我用移动选项动态创建按钮。实际上我有表单,因为我把面板与backroundimage作为Dock = Fill,在面板中我创建按钮动态地,我需要使按钮变得透明,即我需要通过动态创建的按钮来查看面板图像。因此需要使按钮成为透明的。

i我试试这个

  Dim  btn 作为 按钮
btn.Parent = .ContainerSLD
Dim buttonBackground 作为 位图(btn.Width,btn.Height)
使用 g As Graphics = Graphics.FromImage(buttonBackground)
g.DrawImage( Me .ContainerSLD .BackgroundImage,矩形( 0 0 ,buttonBackground.Width, buttonBackground.Height),btn.Bounds,GraphicsUnit.Pixel)
结束 使用
btn.BackgroundImage = buttonBackground





但它不会改变transparaent。

请回复我asap



问候

Aravind

解决方案

只需将flatstyle设置为Flat ,背景颜色是否透明?


可能是



1.remove

 btn.BackgroundImage = buttonBackground 





2.write

 btn.BackColor = color.Transparent 


试试这个

Dim alpha AS Int16

alpha = 60

Button1.BackColor = Color.FromARGB(alpha,SystemColor.Control)


Hai
i am developing windows application,in that i create buttons dynamically with move options.actually i have form ,in that i put panel with backroundimage as Dock=Fill,in panel i am create buttons dynamically,i need to make buttons as transparent,i.e i need to see panel image via buttons as created dynamically.so need to make button as transparaent.
i am try this

Dim btn As New Button
btn.Parent = Me.ContainerSLD
Dim buttonBackground As New Bitmap(btn.Width, btn.Height)
Using g As Graphics = Graphics.FromImage(buttonBackground)
    g.DrawImage(Me.ContainerSLD.BackgroundImage, New Rectangle(0, 0, buttonBackground.Width, buttonBackground.Height), btn.Bounds, GraphicsUnit.Pixel)
End Using
btn.BackgroundImage = buttonBackground



but it not change transparaent.
pls reply me asap

Regards
Aravind

解决方案

just set the flatstyle to Flat, and the background color to transparent?


may be

1.remove

btn.BackgroundImage = buttonBackground



2.write

btn.BackColor=color.Transparent


try this
Dim alpha AS Int16
alpha = 60
Button1.BackColor = Color.FromARGB(alpha,SystemColor.Control)


这篇关于如何在vb.net中将按钮更改为透明?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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