欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

vb.net菜單背景 vb窗體背景怎么設(shè)置

vb.net中,如何實(shí)現(xiàn)鼠標(biāo)在listbox控件上移動(dòng)時(shí),鼠標(biāo)所到的條目背景變黑、字變白;移開后還原?

復(fù)雜的不會(huì),來點(diǎn)兒簡(jiǎn)單的,借用在listbox里按下鼠標(biāo)時(shí)再移動(dòng),會(huì)高亮顯示選擇行,并且會(huì)隨鼠標(biāo)移動(dòng)而變化的這一特點(diǎn)改進(jìn)的,不足之處是在listbox里,此時(shí)處于鼠標(biāo)左鍵在按下狀態(tài)。

創(chuàng)新互聯(lián)服務(wù)項(xiàng)目包括禹會(huì)網(wǎng)站建設(shè)、禹會(huì)網(wǎng)站制作、禹會(huì)網(wǎng)頁制作以及禹會(huì)網(wǎng)絡(luò)營(yíng)銷策劃等。多年來,我們專注于互聯(lián)網(wǎng)行業(yè),利用自身積累的技術(shù)優(yōu)勢(shì)、行業(yè)經(jīng)驗(yàn)、深度合作伙伴關(guān)系等,向廣大中小型企業(yè)、政府機(jī)構(gòu)等提供互聯(lián)網(wǎng)行業(yè)的解決方案,禹會(huì)網(wǎng)站推廣取得了明顯的社會(huì)效益與經(jīng)濟(jì)效益。目前,我們服務(wù)的客戶以成都為中心已經(jīng)輻射到禹會(huì)省份的部分城市,未來相信會(huì)繼續(xù)擴(kuò)大服務(wù)區(qū)域并繼續(xù)獲得客戶的支持與信任!

Declare Sub mouse_event Lib "user32" (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)

Public Const MOUSEEVENTF_LEFTDOWN = H2 '模擬鼠標(biāo)左鍵按下

Private Sub ListBox1_MouseMove(sender As Object, e As MouseEventArgs) Handles ListBox1.MouseMove

mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)

End Sub

VB.NET菜單設(shè)計(jì)初級(jí)入門[3]

五.繪制個(gè)性化菜單

先執(zhí)行以下操作步驟 下列步驟是通過菜單編輯器設(shè)計(jì)一個(gè)簡(jiǎn)單的菜單 為后面重新繪制做基礎(chǔ)

啟動(dòng)Visual Studio Net

選擇菜單【文件】|【新建】|【項(xiàng)目】后 彈出【新建項(xiàng)目】對(duì)話框

將【項(xiàng)目類型】設(shè)置為【Visual Basic項(xiàng)目】

將【模板】設(shè)置為【W(wǎng)indows應(yīng)用程序】

在【名稱】文本框中輸入【自己畫菜單】

在【位置】的文本框中輸入【E:\VS NET項(xiàng)目】 然后單擊【確定】按鈕 這樣在 E:\VS NET項(xiàng)目 目錄中就產(chǎn)生了名稱為 自己畫菜單 的文件夾 并在里面創(chuàng)建了名稱為 自己畫菜單 的項(xiàng)目文件

把Visual Studio Net的當(dāng)前窗口切換到【Form vb(設(shè)計(jì))】窗口 并從【工具箱】中的【W(wǎng)indows窗體組件】選項(xiàng)卡中往Form 窗體中拖入下列組件

一個(gè)MainMenu組件 名稱為 MainMenu

選中 MainMenu 組件 單擊鼠標(biāo)右鍵 在彈出的菜單中選擇 編輯菜單 并按照?qǐng)D 所示界面設(shè)計(jì)菜單

圖 【自己畫菜單】項(xiàng)目設(shè)計(jì)界面之一

此時(shí)保存上述步驟 并單擊快捷鍵F 則得到圖 所示界面

圖 【自己畫菜單】運(yùn)行界面之一

這樣通過菜單編輯器就完成了一個(gè)非常普通的菜單 下面就對(duì)此菜單進(jìn)行改造 在改造之前 要先設(shè)定項(xiàng)目中的三個(gè)MenuItem類實(shí)例的OwnerDraw屬性值為 True 因?yàn)橹挥写藢傩灾禐?True 才會(huì)觸發(fā)繪制菜單時(shí)所需要的DrawItem事件和MeasureItem事件 之后再在上面項(xiàng)目的基礎(chǔ)上執(zhí)行下一步操作

把Visual Stuido Net的當(dāng)前窗口切換到Form vb的代碼編輯窗口 并在InitializeComponent過程之后添加下列代碼 下列代碼是繪制 文件 菜單項(xiàng) 其作用是改變 文件 菜單項(xiàng)的字體 大小和菜單項(xiàng)的 其具體的繪制方法請(qǐng)參考下列代碼中的注釋

Private Sub MenuItem _DrawItem ( ByVal sender As Object ByVal e As System Windows Forms DrawItemEventArgs ) Handles MenuItem DrawItem Dim rfBound As RectangleF = New RectangleF ( e Bounds X e Bounds Y e Bounds Width e Bounds Height )  根據(jù)DrawItemEventArgs參數(shù)獲得菜單項(xiàng)矩形區(qū)域并存儲(chǔ)到RectangleF類型實(shí)例中 Dim rfBound As Rectangle = New Rectangle ( e Bounds X e Bounds Y e Bounds Width e Bounds Height )  根據(jù)DrawItemEventArgs參數(shù)獲得菜單項(xiàng)矩形區(qū)域并存儲(chǔ)到Rectangle類型實(shí)例中  Rectangle類型實(shí)例和RectangleF類型實(shí)例差不多 但在后面代碼中繪制菜單的函數(shù)是有區(qū)別的  e Graphics FillRectangle(New SolidBrush(Color LightGreen) rfBound) 以LightGreen色彩填充MenuItem 菜單項(xiàng)對(duì)應(yīng)的矩形區(qū)域 Dim s As MenuItem = CType ( sender MenuItem ) Dim s As String = s Text  獲得MenuItem 菜單項(xiàng)的名稱 Dim sfTemp As StringFormat = New StringFormat ( ) sfTemp Alignment = StringAlignment Center  設(shè)定要畫的菜單名稱的對(duì)齊方式 中間對(duì)齊 e Graphics DrawString ( s New Font ( 宋體 FontStyle Bold ) New SolidBrush ( Color Black ) rfBound sfTemp )  以中間對(duì)齊方式 指定字體 大小 在指定的矩形區(qū)域重畫菜單 If e State = ( DrawItemState NoAccelerator Or DrawItemState Selected ) Then 根據(jù)菜單項(xiàng)的當(dāng)前繪制狀態(tài)來繪制菜單項(xiàng) e Graphics FillRectangle ( New SolidBrush ( Color LightYellow ) rfBound ) 對(duì)菜單項(xiàng)所在的矩形區(qū)域進(jìn)行色彩填充 e Graphics DrawString ( s New Font ( 宋體 FontStyle Bold ) New SolidBrush ( Color Black ) rfBound sfTemp )  對(duì)菜單項(xiàng)名稱繪制 End If e DrawFocusRectangle ( )  在 DrawItemEventArgs參數(shù)得到矩形范圍內(nèi)繪制聚焦框  e Graphics DrawRectangle ( New Pen ( New SolidBrush ( Color Black ) ) rfBound )  對(duì)菜單項(xiàng)的矩形區(qū)域繪制矩形框End Sub

操作完成后 保存修改 此時(shí)再單擊快捷鍵F 運(yùn)行程序 可得到如圖 所示的界面

圖 【自己畫菜單】運(yùn)行界面之二

可見繪制的 文件 菜單項(xiàng)并沒有完全顯示出來 并且后面的菜單項(xiàng)也沒有顯示 這是因?yàn)椴藛雾?xiàng)的顯示區(qū)域并沒有設(shè)定 而缺省的空間又不能完全顯示造成的 設(shè)定菜單項(xiàng)的顯示區(qū)域大小是通過MeasureItem事件來完成的 具體操作是在MenuItem 的DrawItem事件后添加下列代碼 下列代碼是是定義MenuItem 的MeasureItem事件 在此事件中設(shè)定菜單項(xiàng)的寬度(當(dāng)然也可以設(shè)定高度等)

Private Sub MenuItem _MeasureItem ( ByVal sender As Object ByVal e As System Windows Forms MeasureItemEventArgs ) Handles MenuItem MeasureItem e ItemWidth =   設(shè)定菜單項(xiàng)的寬度End Sub

保存上述修改后 單擊快捷鍵F 運(yùn)行程序可得到圖 所示界面

圖 【自己畫菜單】運(yùn)行界面之三

可見 文件 菜單項(xiàng)就算繪制出來了 由于其他菜單項(xiàng)沒有繪制處理 所以也未顯示 其他菜單項(xiàng)的繪制方法和 文件 菜單項(xiàng)的繪制方法基本相似 以下是在上述完成的基礎(chǔ)上 對(duì)其他菜單項(xiàng)進(jìn)行繪制 從而得到圖 所示菜單的具體實(shí)現(xiàn)步驟

圖 【自己畫菜單】運(yùn)行界面之四

在Form vb中的MenuItem 的MeasureItem事件處理程序之后添加下列代碼 下列代碼是定義MenuItem 的DrawItem事件 其功能是對(duì) 新建 菜單項(xiàng)重新繪制

Private Sub MenuItem _DrawItem ( ByVal sender As Object ByVal e As System Windows Forms DrawItemEventArgs ) Handles MenuItem DrawItem Dim rfBound As RectangleF = New RectangleF ( e Bounds X e Bounds Y e Bounds Width e Bounds Height )   根據(jù)DrawItemEventArgs參數(shù)獲得菜單項(xiàng)矩形區(qū)域并存儲(chǔ)到RectangleF類型實(shí)例中 Dim rfBound As Rectangle = New Rectangle ( e Bounds X e Bounds Y e Bounds Width e Bounds Height )   根據(jù)DrawItemEventArgs參數(shù)獲得菜單項(xiàng)矩形區(qū)域并存儲(chǔ)到Rectangle類型實(shí)例中  Rectangle類型實(shí)例和RectangleF類型實(shí)例差不多 但在后面代碼中繪制菜單的函數(shù)是有區(qū)別的 e Graphics FillRectangle ( New SolidBrush ( Color LightGray ) rfBound )  Dim s As MenuItem = CType ( sender MenuItem )  Dim s As String = s Text  獲得菜單項(xiàng)對(duì)應(yīng)的文本名稱 Dim sfTemp As StringFormat = New StringFormat ( )  sfTemp Alignment = StringAlignment Center  設(shè)定文本在矩形區(qū)域的對(duì)齊方式 sfTemp LineAlignment = StringAlignment Center Dim rcText As RectangleF = rfBound rcText Width =  e Graphics DrawString ( s New Font ( 宋體 ) New SolidBrush ( Color Blue ) rcText sfTemp )  e Graphics DrawRectangle ( New Pen ( New SolidBrush ( Color LightGray ) ) rfBound )  If e State = ( DrawItemState NoAccelerator Or DrawItemState Selected ) Thene Graphics FillRectangle ( New SolidBrush ( Color LightYellow ) rfBound ) e Graphics DrawString ( s New Font ( 宋體 FontStyle Bold Or FontStyle Underline ) New SolidBrush ( Color Red ) rcText sfTemp ) e Graphics DrawRectangle ( New Pen ( New SolidBrush ( Color Black ) ) rfBound ) e DrawFocusRectangle ( )  End IfEnd Sub

MenuItem 的DrawItem事件處理代碼之后添加下列代碼 下列代碼是定義MenuItem 的MeasureItem事件 在此事件中實(shí)現(xiàn)設(shè)定 新建 菜單項(xiàng)的長(zhǎng)度和高度

Private Sub MenuItem _MeasureItem ( ByVal sender As Object ByVal e As System Windows Forms MeasureItemEventArgs ) Handles MenuItem MeasureItem e ItemWidth =   設(shè)定菜單項(xiàng)的寬度 e ItemHeight =   設(shè)定菜單項(xiàng)的高度End Sub

在完成上述操作步驟后 再在MenuItem 的MeasureItem事件處理程序之后添加下列代碼 下列代碼是定義MenuItem 的DrawItem事件 其功能是對(duì) 打開 菜單項(xiàng)重新繪制

Private Sub MenuItem _DrawItem ( ByVal sender As Object ByVal e As System Windows Forms DrawItemEventArgs ) Handles MenuItem DrawItemDim rfBound As RectangleF = New RectangleF ( e Bounds X e Bounds Y e Bounds Width e Bounds Height ) 根據(jù)DrawItemEventArgs參數(shù)獲得菜單項(xiàng)矩形區(qū)域并存儲(chǔ)到RectangleF類型實(shí)例中Dim rfBound As Rectangle = New Rectangle ( e Bounds X e Bounds Y e Bounds Width e Bounds Height ) 根據(jù)DrawItemEventArgs參數(shù)獲得菜單項(xiàng)矩形區(qū)域并存儲(chǔ)到Rectangle類型實(shí)例中 Rectangle類型實(shí)例和RectangleF類型實(shí)例差不多 但在后面代碼中繪制菜單的函數(shù)是有區(qū)別的Dim s As MenuItem = CType ( sender MenuItem ) Dim s As String = s TextDim sfTemp As StringFormat = New StringFormat ( ) sfTemp Alignment = StringAlignment CentersfTemp LineAlignment = StringAlignment CenterDim rcText As RectangleF = rfBoundrcText Width = e Graphics DrawString ( s New Font ( Veranda ) New SolidBrush ( Color Blue ) rcText sfTemp ) e Graphics DrawRectangle ( New Pen ( New SolidBrush ( Color LightGray ) ) rfBound ) If e State = ( DrawItemState NoAccelerator Or DrawItemState Selected ) Then e Graphics FillRectangle ( New SolidBrush ( Color LightYellow ) rfBound )  e Graphics DrawString ( s New Font ( Veranda FontStyle Bold Or FontStyle Underline ) New SolidBrush ( Color Red ) rcText sfTemp )  e Graphics DrawRectangle ( New Pen ( New SolidBrush ( Color Black ) ) rfBound )  e DrawFocusRectangle ( ) End IfEnd Sub

MenuItem 的DrawItem事件處理代碼之后添加下列代碼 下列代碼是定義MenuItem 的MeasureItem事件 在此事件中實(shí)現(xiàn)設(shè)定 新建 菜單項(xiàng)的長(zhǎng)度和高度

Private Sub MenuItem _MeasureItem ( ByVal sender As Object ByVal e As System Windows Forms MeasureItemEventArgs ) Handles MenuItem MeasureItem e ItemWidth =   設(shè)定菜單項(xiàng)的寬度 e ItemHeight =   設(shè)定菜單項(xiàng)的高度End Sub

在上述步驟都正確完成后 本文介紹的手工繪制菜單就完成 此時(shí)單擊快捷鍵F 運(yùn)行 程序就可以得到圖 所示的運(yùn)行界面

六.總結(jié)

本文主要內(nèi)容是介紹VB NET設(shè)計(jì)和創(chuàng)建菜單 其中不僅介紹了使用菜單設(shè)計(jì)器來靜態(tài)設(shè)計(jì)菜單 還介紹了使用MainMenu類 MenuItem類和ContextMenu類動(dòng)態(tài)創(chuàng)建菜單的實(shí)現(xiàn)方法 在動(dòng)態(tài)創(chuàng)建時(shí) 首先要了解要?jiǎng)?chuàng)建的菜單類型 是下拉菜單 首先要?jiǎng)?chuàng)建一個(gè)MainMenu實(shí)例 是彈出菜單 首先要?jiǎng)?chuàng)建一個(gè)ContextMenu實(shí)例 然后根據(jù)菜單中的組成結(jié)構(gòu) 即菜單項(xiàng)中的父子關(guān)系 創(chuàng)建出相應(yīng)菜單 最后就是顯示出菜單 如果是下拉菜單 指派給Form的Menu屬性 如果是彈出菜單 指派給可視組件或Form的ContextMenu屬性 這樣動(dòng)態(tài)創(chuàng)建菜單才能夠顯示出來 動(dòng)態(tài)創(chuàng)建菜單的工作才算完成

此外還介紹了在Visual Basic Net中繪制個(gè)性化菜單的實(shí)現(xiàn)方法和注意事項(xiàng) 在繪制個(gè)性化菜單時(shí)最重要的是掌握DrawItem事件和MeasureItem事件用法 及繪制菜單時(shí)所要使用到的方法 雖然本文繪制的菜單并不美觀 但你可以通過本文介紹的方法來修改 從而實(shí)現(xiàn)更美觀 更有個(gè)性的菜單 最后請(qǐng)記住 在繪制菜單時(shí) 首先把菜單項(xiàng)的 OwnerDraw 屬性設(shè)定為 True

lishixinzhi/Article/program/net/201311/15454

在VB.NET中改變窗體背景顏色,窗體上的其他控件背景顏色也變了,為什么?

其他機(jī)器是只同一個(gè)程序 還是 是不是應(yīng)為你的其他軟件的背景色是透明的呢

vb.net窗口背景

試試調(diào)整之前

Me.SuspendLayout()

調(diào)整完之后再

Me.ResumeLayout()

VB.net如何移除菜單了豎條?

當(dāng)年用vb6時(shí),千方百計(jì)的要改成帶這個(gè)條的,你現(xiàn)有了還要?jiǎng)h除,真是沒見過。

這里是用來放圖標(biāo),復(fù)選等的,我認(rèn)為帶著好看多了。

vb.net 菜單控件出來的菜單樣式如何修改?vs沒提供其它樣式嗎?比如xp下的樣式,不想要那菜單左

這個(gè)很麻煩的,需要自己重寫菜單的繪制事件,然后自己繪制新菜單。

自己繪制的菜單可以是你能想到的各種新奇有趣的樣式。

VB.NET沒提供直接改變成其它菜單的方法。

網(wǎng)站欄目:vb.net菜單背景 vb窗體背景怎么設(shè)置
分享網(wǎng)址:http://chinadenli.net/article0/dooodio.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供虛擬主機(jī)、網(wǎng)站維護(hù)、商城網(wǎng)站網(wǎng)站營(yíng)銷、Google、外貿(mào)網(wǎng)站建設(shè)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

h5響應(yīng)式網(wǎng)站建設(shè)