日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
VB.NET制作圖片按鈕實現(xiàn)步驟一一講解

VB.NET是目前應(yīng)用比較廣泛的編程語言。它在文件處理,移動設(shè)備操作,圖形界面的處理方面都能夠體現(xiàn)強大的作用。那么今天我們就一起學習一個其中的應(yīng)用技巧,VB.NET制作圖片按鈕的實際操作方法。

公司主營業(yè)務(wù):成都網(wǎng)站制作、網(wǎng)站設(shè)計、移動網(wǎng)站開發(fā)等業(yè)務(wù)。幫助企業(yè)客戶真正實現(xiàn)互聯(lián)網(wǎng)宣傳,提高企業(yè)的競爭能力。創(chuàng)新互聯(lián)公司是一支青春激揚、勤奮敬業(yè)、活力青春激揚、勤奮敬業(yè)、活力澎湃、和諧高效的團隊。公司秉承以“開放、自由、嚴謹、自律”為核心的企業(yè)文化,感謝他們對我們的高要求,感謝他們從不同領(lǐng)域給我們帶來的挑戰(zhàn),讓我們激情的團隊有機會用頭腦與智慧不斷的給客戶帶來驚喜。創(chuàng)新互聯(lián)公司推出潁上免費做網(wǎng)站回饋大家。

VB.NET制作圖片按鈕思路:很簡單,就是在一個picturebox控件上放置一個button控件,然后將這個button添加進picturebox上(確保先拖拽picturebox,后拖拽button),設(shè)置這個button的背景色(這個時候是相對于picturebox)為透明。

 
 
 
  1. Imports System.ComponentModel 
  2. Public Class picturebutton 
  3. Inherits System.Windows.Forms.UserControl 
  4. #Region " Windows 窗體設(shè)計器生成的代碼 " 
  5. 'UserControl 重寫 dispose 以清理組件列表。 
  6. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) 
  7. If disposing Then 
  8. If Not (components Is Nothing) Then 
  9. components.Dispose() 
  10. End If 
  11. End If 
  12. MyBase.Dispose(disposing) 
  13. End Sub 
  14. 'Windows 窗體設(shè)計器所必需的 
  15. Private components As System.ComponentModel.IContainer 

注意:以下VB.NET制作圖片按鈕的過程是 Windows 窗體設(shè)計器所必需的

可以使用 Windows 窗體設(shè)計器修改此過程。

不要使用代碼編輯器修改它。

 
 
 
  1. Friend WithEvents PictureBox1 As System.Windows.Forms.PictureBox 
  2. Friend WithEvents Button1 As System.Windows.Forms.Button 
  3.  
    Private Sub InitializeComponent() 
  4. Me.PictureBox1 = New System.Windows.Forms.PictureBox() 
  5. Me.Button1 = New System.Windows.Forms.Button() 
  6. Me.SuspendLayout() 
  7. 'PictureBox1 
  8. Me.PictureBox1.Name = "PictureBox1" 
  9. Me.PictureBox1.Size = New System.Drawing.Size(136, 40) 
  10. Me.PictureBox1.TabIndex = 0 
  11. Me.PictureBox1.TabStop = False 
  12. 'Button1 
  13. Me.Button1.Name = "Button1" 
  14. Me.Button1.TabIndex = 1 
  15. Me.Button1.Text = "Button1" 
  16. 'picturebutton 
  17. Me.Controls.AddRange(New System.Windows.Forms.Control() 
    {Me.Button1, Me.PictureBox1}) 
  18. Me.Name = "picturebutton" 
  19. Me.ResumeLayout(False) 
  20. End Sub 
  21. #End Region 
  22. Public Sub New() 
  23. MyBase.New() 

該調(diào)用是 Windows 窗體設(shè)計器所必需的。

 
 
 
  1. InitializeComponent() 
  2. '在 InitializeComponent() 調(diào)用之后添加任何初始化 
  3. Me.Button1.Width = 100 ‘設(shè)置按鈕的初始大小 
  4. Me.Button1.Height = 23 
  5. Me.Button1.BackColor = Color.Transparent ‘背景色透明 
  6. Me.Button1.ForeColor = Color.Black 
  7. Me.PictureBox1.Controls.Add(Me.Button1) 
  8. End Sub 
  9. Private m_text As String ‘設(shè)置按鈕標題 
  10. Private a As Integer 
  11. 'Private m_image As Image 
  12.  _ 
  13. Public Property image() As image 
  14. Get 
  15. Return Me.PictureBox1.Image 
  16. End Get 
  17. Set(ByVal Value As image) 
  18. Me.PictureBox1.Image = Value 
  19. Invalidate() 
  20. End Set 
  21. End Property 
  22. Shadows Property forecolor() As Color 
  23. Get 
  24. Return Me.Button1.ForeColor 
  25. End Get 
  26. Set(ByVal Value As Color) 
  27. Me.Button1.ForeColor = Value 
  28. Invalidate() 
  29. End Set 
  30. End Property 
  31. Shadows Sub ResetForeColor() 
  32. Me.Button1.ForeColor = SystemColors.ControlText 
  33. End Sub 

VB.NET制作圖片按鈕的單擊事件

 
 
 
  1. Event BtnClick(ByVal sender As Object, ByVal e As System.EventArgs) 
  2. Private Sub Button1_Click(ByVal sender As Object, 
    ByVal e As System.EventArgs) Handles Button1.Click 
  3. RaiseEvent BtnClick(Me, e) 
  4. End Sub 

控件改變大小時,需重繪控件,以使子控件排位美觀

 
 
 
  1. Private Sub FileTextBox_Resize(ByVal sender As Object,
     ByVal e As System.EventArgs) Handles MyBase.Resize 
  2. RedrawControls() 
  3. End Sub 

子控件會自動繼續(xù)容器的Font屬性,所以改變?nèi)萜鞯腇ont屬性時也要重繪控件

 
 
 
  1. Protected Overrides Sub OnFontChanged(ByVal e As System.EventArgs) 
  2. '讓基控件更新文本框 
  3. MyBase.OnFontChanged(e) 
  4. '重繪控件 
  5. RedrawControls() 
  6. End Sub 
  7. '重繪控件 
  8. Private Sub RedrawControls() 
  9. '控件寬度 
  10. Dim width As Integer = Me.ClientRectangle.Width '獲得工作區(qū)寬 

以VB.NET制作圖片按鈕的高度來確定控件高度

 
 
 
  1. Dim btnSide As Integer = Button1.Height 
  2. Dim btnwidth As Integer = Button1.Width 
  3. If Me.ClientRectangle.Height <> btnSide Then 

設(shè)置控件工作區(qū)的大小

 
 
 
  1. 'Me.SetClientSizeCore(btnwidth, btnSide) 
  2. Me.SetClientSizeCore(width, btnSide)
  3. '這里使用工作區(qū)的寬是因為:按鈕和picturebox可以調(diào)整寬度 
  4. '上面的語句激發(fā)了嵌套的Resize事件,因此需要立即退出,
    如果不退出,就會反復調(diào)用進入死循環(huán) 
  5. Exit Sub 
  6. End If 

調(diào)整子控件的大小

 
 
 
  1. 'Txt.SetBounds(0, 0, width, btnSide) 
  2. 'Btn.SetBounds(width - 19, 2, 17, btnSide - 4) 
  3. Me.PictureBox1.SetBounds(0, 0, width, btnSide) 
  4. Me.PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage 
  5. Me.Button1.SetBounds(0, 0, width, btnSide) 
  6. End Sub 
  7. End Class 

VB.NET制作圖片按鈕的相關(guān)實現(xiàn)方法就為大家介紹到這里。


文章標題:VB.NET制作圖片按鈕實現(xiàn)步驟一一講解
文章分享:http://m.5511xx.com/article/djpschj.html