vb.net 怎么把button变成圆形 我想要指示灯的效果

qq_36086921 2017-06-07 04:44:01
如题
...全文
1411 7 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
wanghui0380 2017-06-30
  • 打赏
  • 举报
回复
请百(谷)度(哥)“ControlPaint.DrawBorder”
OneCoderr 2017-06-30
  • 打赏
  • 举报
回复
如果只是显示,用picturebox吧。 其实用方形的label也很好的。
ownding 2017-06-27
  • 打赏
  • 举报
回复
可以采用这个方法:

Imports System.Runtime.InteropServices

Public Class btn

<DllImport("Gdi32.dll", EntryPoint:="CreateRoundRectRgn")>
Private Shared Function CreateRoundRectRgn(ByVal iLeft As Integer, ByVal iTop As Integer, ByVal iRight As Integer, ByVal iBottom As Integer, ByVal iWidth As Integer, ByVal iHeight As Integer) As IntPtr
End Function

Dim btnstart As New Button()

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load
With btnstart
.Text = "Start"
'.TextAlign = ContentAlignment.MiddleCenter
.Height = 100
.Width = 100
.Location = New Point(720, -40)
.Region = System.Drawing.Region.FromHrgn(CreateRoundRectRgn(50, 50, btnstart.Width - 2, btnstart.Height - 2, 50, 50))
.BackColor = Color.Red
.Visible = True
.ForeColor = Color.Black
End With

Me.Controls.Add(btnstart)
AddHandler btnstart.Click, AddressOf startupdate '绑定事件
End Sub

End Class



上图绿色就是圆形的button,在Form1_Load初始的时候是红色的。
caoqinghua 2017-06-26
  • 打赏
  • 举报
回复
别难为button了. 一种方案用gdi+自己绘制.另外一种直接上图片 .
im战术 2017-06-07
  • 打赏
  • 举报
回复
我自己好像是用的GIF图片做过
qq_36086921 2017-06-07
  • 打赏
  • 举报
回复
有没有其他形式可以实现。。。
im战术 2017-06-07
  • 打赏
  • 举报
回复
只能剪出一个圆形按钮

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim a As New GraphicsPath()
        a.AddEllipse(25, 6, 25, 25)
        Button1.Region = New Region(a)

        Button1.Text = "Btn"
        Button1.Height = 38
    End Sub
但真的不好看没有边框,

16,722

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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