真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

包含vb.netforms的詞條

如何實(shí)現(xiàn)vb.net中form全屏化

把任務(wù)欄隱藏了再把form最大化

威遠(yuǎn)ssl適用于網(wǎng)站、小程序/APP、API接口等需要進(jìn)行數(shù)據(jù)傳輸應(yīng)用場(chǎng)景,ssl證書未來市場(chǎng)廣闊!成為創(chuàng)新互聯(lián)的ssl證書銷售渠道,可以享受市場(chǎng)價(jià)格4-6折優(yōu)惠!如果有意向歡迎電話聯(lián)系或者加微信:13518219792(備注:SSL證書合作)期待與您的合作!

[DllImport("user32.dll")]

private static extern int ShowWindow(IntPtr hWnd, int nCmdShow);

[DllImport("User32.dll", CharSet=CharSet.Auto)]

private static extern IntPtr FindWindow(string lpClassName, string lpWindowName);

private const int SW_SHOW = 5;

private const int SW_HIDE = 0;

IntPtr handle;

int result;

//獲取任務(wù)欄窗口的句柄

//Shell_TrayWnd是任務(wù)欄的窗口名

handle = FindWindow("Shell_TrayWnd", null); result = ShowWindow(handle, SW_SHOW); //顯示

result = ShowWindow(handle, SW_HIDE); //隱藏

vb.net如何寫在form1上右鍵被單擊的事件?

如果是窗體右鍵單擊事件,是

Private Sub Form1_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseClick

If e.Button = Windows.Forms.MouseButtons.Right Then

'這里寫你要的代碼

End If

End Sub

但是如果只是右鍵單擊就彈出菜單的話沒必要這樣,只需要在窗體上放置一個(gè)ContextMenuStrip控件,然后在Form的ContextMenuStrip屬性中綁定這個(gè)控件就可以了。

VB.NET中如何不使用system.windows.forms.openfiledialog控件即可實(shí)現(xiàn)類似效果?

可以實(shí)現(xiàn)

首先創(chuàng)建一個(gè)Button類型控件數(shù)組:

1、創(chuàng)建“Windows應(yīng)用程序”類型的工程,添加名為ButtonArray的類,并使該類繼承 System.Collection.CollectionBase 類。System.Collections.CollectionBase類是.NET框架類庫中為集合操作提供抽象的基類,通過對(duì)它的繼承可以為我們的ButtonArray類具備集合增加、刪除、索引的功能。

2、為ButtonArray類添加ParentForm屬性,即控件組所在窗體,創(chuàng)建初始化函數(shù)(構(gòu)造函數(shù));

3、為控件數(shù)組類增加AddItem方法,該方法在控件數(shù)組類中添加成員;

4、為控件數(shù)組類增加RemoveItem方法,該方法在控件數(shù)組中刪除一個(gè)成員。

示例代碼:

Public Class ButtonArray

Inherits System.Collections.CollectionBase

Private ReadOnly ParentForm As System.Windows.Forms.Form

Public Sub New(ByVal pForm As System.Windows.Forms.Form)

ParentForm = pForm

End Sub

Default Public ReadOnly Property Item(ByVal index As Integer) As System.Windows.Forms.Button

Get

Return Me.List.Item(index) ' ButtonArray的List 屬性從CollectionBase 繼承

End Get

End Property

Public Sub AddItem()

Dim btnItem As New System.Windows.Forms.Button

Me.List.Add(btnItem)

ParentForm.Controls.Add(btnItem) '向窗體中增加控件

btnItem.Tag = Me.Count 'Count屬性從CollectionBase 繼承

btnItem.Top = Me.Count * 30

btnItem.Left = 200

btnItem.Text = "Button" Me.Count.ToString

AddHandler btnItem.Click, AddressOf btnItem_Click '綁定事件處理程序

End Sub

Public Sub AddItem(ByVal btnItem As System.Windows.Forms.Button)

Me.List.Add(btnItem)

AddHandler btnItem.Click, AddressOf btnItem_Click '綁定事件處理程序

End Sub

Public Sub RemoveItem()

If Me.Count 0 Then

ParentForm.Controls.Remove(Me(Me.Count - 1))

Me.List.RemoveAt(Me.Count - 1)

End If

End Sub

Public Sub btnItem_Click(ByVal sender As Object, ByVal e As System.EventArgs)

'在這里編寫控件數(shù)組對(duì)點(diǎn)擊事件的響應(yīng)

'例如:

MsgBox("點(diǎn)擊:" sender.GetType().ToString CType(CType(sender, Button).Tag, String))

End Sub

End Class

使用創(chuàng)建的控件數(shù)組

在Form1中放置兩個(gè)按鈕Button1、Button2,分別測(cè)試控件數(shù)組的增添、刪除。

雙擊Form添加代碼:

Public Class Form1

Inherits System.Windows.Forms.Form

……Windows窗體設(shè)計(jì)器生成的代碼……

Dim Buttons As New ButtonArray(Me)

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Buttons.AddItem()

End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

Buttons.RemoveItem()

End Sub

End Class

其他的控件數(shù)組也可以用類似的方式來實(shí)現(xiàn)

例如 Label控件數(shù)組

LabelArray.vb代碼如下:

Public Class LabelArray

Inherits System.Collections.CollectionBase

Private ReadOnly ParentForm As System.Windows.Forms.Form

Public Sub New(ByVal pForm As System.Windows.Forms.Form)

ParentForm = pForm

End Sub

Default Public ReadOnly Property Item(ByVal index As Integer) As System.Windows.Forms.Label

Get

Return Me.List.Item(index) ' ButtonArray的List 屬性從CollectionBase 繼承

End Get

End Property

Public Sub AddItem(ByVal btnItem As System.Windows.Forms.Label)

Me.List.Add(btnItem)

AddHandler btnItem.Click, AddressOf btnItem_Click '綁定事件處理程序

End Sub

Public Sub btnItem_Click(ByVal sender As Object, ByVal e As System.EventArgs)

'在這里編寫控件數(shù)組對(duì)點(diǎn)擊事件的響應(yīng)

'例如:

MsgBox("點(diǎn)擊:" sender.GetType().ToString CType(CType(sender, Label).Tag, String))

End Sub

End Class

使用創(chuàng)建的Label控件

在Form1中放置兩個(gè)按鈕Label1、Label2

雙擊Form添加代碼:

Public Class Form1

Inherits System.Windows.Forms.Form

#Region " Windows 窗體設(shè)計(jì)器生成的代碼 "

Public Sub New()

MyBase.New()

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

InitializeComponent()

'在 InitializeComponent() 調(diào)用之后添加任何初始化

'用來綁定label

BindArray()

End Sub

……Windows窗體設(shè)計(jì)器生成的其他代碼……

#End Region

Dim Labels As New LabelArray(Me)

Public Sub BindArray()

Me.Label1.Tag = "1111"

Me.Label2.Tag = "222"

Labels.AddItem(Me.Label1)

Labels.AddItem(Me.Label2)

End Sub

End Class

然后可以測(cè)試點(diǎn)擊兩個(gè)label可以顯示相應(yīng)的Tag的信息。

如何給VB.NET窗體添加子窗體?

直接添加一個(gè)MID父窗體或在已有窗體的屬性中找到IsMDIContainer屬性,然后設(shè)置為True,然后創(chuàng)建第二個(gè)窗體 ,需要加載子窗體的時(shí)候:

Dim NewMDIChild As New Form2

NewMDIChild.MdiParent = Me

NewMDIChild.Show()

Public?Shared?Sub?CheckMDIChildForm(ByVal?MDIForm?As?Windows.Forms.Form,?ByVal?MDIChildForm?As?Windows.Forms.Form,?ByVal?MDIChildFormName?As?String)

If?MDIForm.MdiChildren.Length??1?Then

'如果沒有任何一個(gè)MDI子窗體,則創(chuàng)該MDI子窗體的窗體實(shí)例

Dim?MDIChildFrm?As?Windows.Forms.Form?=?MDIChildForm?'?定義MDI子窗體

MDIChildFrm.MdiParent?=?MDIForm?'指定父窗體

MDIChildFrm.Show()?'打開窗體

Exit?Sub

Else

Dim?x?As?Integer

Dim?frmyn?As?Boolean

For?x?=?0?To?(MDIForm.MdiChildren.Length)?-?1

Dim?tempChild?As?Windows.Forms.Form?=?CType(MDIForm.MdiChildren(x),?Windows.Forms.Form)

If?tempChild.Name?=?MDIChildFormName?Then

'檢測(cè)到有該MDI子窗體,設(shè)為激活?并退出循環(huán)

frmyn?=?True

tempChild.BringToFront()

Exit?For

Else

frmyn?=?False

End?If

Next

If?Not?frmyn?Then

'在打開的窗體中沒檢測(cè)到則新建

Dim?MDIChildFrm?As?Windows.Forms.Form?=?MDIChildForm?'?定義MDI子窗體

MDIChildFrm.MdiParent?=?MDIForm?'指定父窗體

MDIChildFrm.Show()?'打開窗體

End?If

End?If

End?Sub


新聞名稱:包含vb.netforms的詞條
文章轉(zhuǎn)載:http://weahome.cn/article/ddcipdh.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部