1. <ul id="0c1fb"></ul>

      <noscript id="0c1fb"><video id="0c1fb"></video></noscript>
      <noscript id="0c1fb"><listing id="0c1fb"><thead id="0c1fb"></thead></listing></noscript>

      99热在线精品一区二区三区_国产伦精品一区二区三区女破破_亚洲一区二区三区无码_精品国产欧美日韩另类一区

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

      新聞中心

      這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
      關(guān)于vb點(diǎn)虐 事件說明的信息

      vb點(diǎn)虐 中如何用事件和委托,會(huì)C#中的事件和委托,但不知VB點(diǎn)虐 中的語法,望給個(gè)簡(jiǎn)單的例子熟悉語法。

      一委托:此示例演示如何將方法與委托關(guān)聯(lián)然后通過委托調(diào)用該方法。

      江夏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)系或者加微信:18982081108(備注:SSL證書合作)期待與您的合作!

      創(chuàng)建委托和匹配過程

      創(chuàng)建一個(gè)名為 MySubDelegate 的委托。

      Delegate Sub MySubDelegate(ByVal x As Integer)

      聲明一個(gè)類,該類包含與該委托具有相同簽名的方法。

      Class class1

      Sub Sub1(ByVal x As Integer)

      MsgBox("The value of x is: " CStr(x))

      End Sub

      End Class

      定義一個(gè)方法,該方法創(chuàng)建該委托的實(shí)例并通過調(diào)用內(nèi)置的 Invoke 方法調(diào)用與該委托關(guān)聯(lián)的方法。

      Protected Sub DelegateTest()

      Dim c1 As New class1

      ' Create an instance of the delegate.

      Dim msd As MySubDelegate = AddressOf c1.Sub1

      ' Call the method.

      msd.Invoke(10)

      End Sub

      二、事件

      下面的示例程序闡釋如何在一個(gè)類中引發(fā)一個(gè)事件,然后在另一個(gè)類中處理該事件。AlarmClock 類定義公共事件 Alarm,并提供引發(fā)該事件的方法。AlarmEventArgs 類派生自 EventArgs,并定義 Alarm 事件特定的數(shù)據(jù)。WakeMeUp 類定義處理 Alarm 事件的 AlarmRang 方法。AlarmDriver 類一起使用類,將使用 WakeMeUp 的 AlarmRang 方法設(shè)置為處理 AlarmClock 的 Alarm 事件。

      該示例程序使用事件和委托和引發(fā)事件中詳細(xì)說明的概念。

      示例

      ' EventSample.vb.

      '

      Option Explicit

      Option Strict

      Imports System

      Imports System.ComponentModel

      Imports Microsoft.VisualBasic

      Namespace EventSample

      ' Class that contains the data for

      ' the alarm event. Derives from System.EventArgs.

      '

      Public Class AlarmEventArgs

      Inherits EventArgs

      Private _snoozePressed As Boolean

      Private nrings As Integer

      'Constructor.

      '

      Public Sub New(snoozePressed As Boolean, nrings As Integer)

      Me._snoozePressed = snoozePressed

      Me.nrings = nrings

      End Sub

      ' The NumRings property returns the number of rings

      ' that the alarm clock has sounded when the alarm event

      ' is generated.

      '

      Public ReadOnly Property NumRings() As Integer

      Get

      Return nrings

      End Get

      End Property

      ' The SnoozePressed property indicates whether the snooze

      ' button is pressed on the alarm when the alarm event is generated.

      '

      Public ReadOnly Property SnoozePressed() As Boolean

      Get

      Return _snoozePressed

      End Get

      End Property

      ' The AlarmText property that contains the wake-up message.

      '

      Public ReadOnly Property AlarmText() As String

      Get

      If _snoozePressed Then

      Return "Wake Up!!! Snooze time is over."

      Else

      Return "Wake Up!"

      End If

      End Get

      End Property

      End Class

      ' Delegate declaration.

      '

      Public Delegate Sub AlarmEventHandler(sender As Object, _

      e As AlarmEventArgs)

      ' The Alarm class that raises the alarm event.

      '

      Public Class AlarmClock

      Private _snoozePressed As Boolean = False

      Private nrings As Integer = 0

      Private stopFlag As Boolean = False

      ' The Stop property indicates whether the

      ' alarm should be turned off.

      '

      Public Property [Stop]() As Boolean

      Get

      Return stopFlag

      End Get

      Set

      stopFlag = value

      End Set

      End Property

      ' The SnoozePressed property indicates whether the snooze

      ' button is pressed on the alarm when the alarm event is generated.

      '

      Public Property SnoozePressed() As Boolean

      Get

      Return _snoozePressed

      End Get

      Set

      _snoozePressed = value

      End Set

      End Property

      ' The event member that is of type AlarmEventHandler.

      '

      Public Event Alarm As AlarmEventHandler

      ' The protected OnAlarm method raises the event by invoking

      ' the delegates. The sender is always this, the current instance

      ' of the class.

      '

      Protected Overridable Sub OnAlarm(e As AlarmEventArgs)

      RaiseEvent Alarm(Me, e)

      End Sub

      ' This alarm clock does not have

      ' a user interface.

      ' To simulate the alarm mechanism it has a loop

      ' that raises the alarm event at every iteration

      ' with a time delay of 300 milliseconds,

      ' if snooze is not pressed. If snooze is pressed,

      ' the time delay is 1000 milliseconds.

      '

      Public Sub Start()

      Do

      nrings += 1

      If stopFlag Then

      Exit Do

      Else

      If _snoozePressed Then

      System.Threading.Thread.Sleep(1000)

      If (True) Then

      Dim e As New AlarmEventArgs(_snoozePressed, nrings)

      OnAlarm(e)

      End If

      Else

      System.Threading.Thread.Sleep(300)

      Dim e As New AlarmEventArgs(_snoozePressed, nrings)

      OnAlarm(e)

      End If

      End If

      Loop

      End Sub

      End Class

      ' The WakeMeUp class has a method AlarmRang that handles the

      ' alarm event.

      '

      Public Class WakeMeUp

      Public Sub AlarmRang(sender As Object, e As AlarmEventArgs)

      Console.WriteLine((e.AlarmText + ControlChars.Cr))

      If Not e.SnoozePressed Then

      If e.NumRings Mod 10 = 0 Then

      Console.WriteLine(" Let alarm ring? Enter Y")

      Console.WriteLine(" Press Snooze? Enter N")

      Console.WriteLine(" Stop Alarm? Enter Q")

      Dim input As String = Console.ReadLine()

      If input.Equals("Y") Or input.Equals("y") Then

      Return

      Else

      If input.Equals("N") Or input.Equals("n") Then

      CType(sender, AlarmClock).SnoozePressed = True

      Return

      Else

      CType(sender, AlarmClock).Stop = True

      Return

      End If

      End If

      End If

      Else

      Console.WriteLine(" Let alarm ring? Enter Y")

      Console.WriteLine(" Stop Alarm? Enter Q")

      Dim input As String = Console.ReadLine()

      If input.Equals("Y") Or input.Equals("y") Then

      Return

      Else

      CType(sender, AlarmClock).Stop = True

      Return

      End If

      End If

      End Sub

      End Class

      ' The driver class that hooks up the event handling method of

      ' WakeMeUp to the alarm event of an Alarm object using a delegate.

      ' In a forms-based application, the driver class is the

      ' form.

      '

      Public Class AlarmDriver

      Public Shared Sub Main()

      ' Instantiates the event receiver.

      Dim w As New WakeMeUp()

      ' Instantiates the event source.

      Dim clock As New AlarmClock()

      ' Wires the AlarmRang method to the Alarm event.

      AddHandler clock.Alarm, AddressOf w.AlarmRang

      clock.Start()

      End Sub

      End Class

      End Namespace

      vb點(diǎn)虐 :聲明事件和引用事件分別用的什么語句

      聲明事件只需用

      private event 事件名稱(參數(shù)表)

      在通用部分聲明

      引用這個(gè)詞不太恰當(dāng),應(yīng)該說是觸發(fā)

      在需要觸發(fā)的地方用

      raiseevent 事件名稱(參數(shù)表)就可以了

      VB.NET的Form的所有事件

      名稱

      說明

      Activated

      當(dāng)使用代碼激活或用戶激活窗體時(shí)發(fā)生。

      AutoSizeChanged

      當(dāng)?AutoSize?屬性更改時(shí)發(fā)生。

      AutoValidateChanged

      當(dāng)?AutoValidate?屬性更改時(shí)發(fā)生。

      BackColorChanged

      當(dāng)?BackColor?屬性的值更改時(shí)發(fā)生。(從?Control?繼承。)

      BackgroundImageChanged

      當(dāng)?BackgroundImage?屬性的值更改時(shí)發(fā)生。(從?Control?繼承。)

      BackgroundImageLayoutChanged

      當(dāng)?BackgroundImageLayout?屬性更改時(shí)發(fā)生。(從?Control?繼承。)

      BindingContextChanged

      當(dāng)?BindingContext?屬性的值更改時(shí)發(fā)生。(從?Control?繼承。)

      CausesValidationChanged

      當(dāng)?CausesValidation?屬性的值更改時(shí)發(fā)生。(從?Control?繼承。)

      ChangeUICues

      焦點(diǎn)或鍵盤用戶界面 (UI) 提示更改時(shí)發(fā)生。(從?Control?繼承。)

      Click

      在單擊控件時(shí)發(fā)生。(從?Control?繼承。)

      ClientSizeChanged

      當(dāng)?ClientSize?屬性的值更改時(shí)發(fā)生。(從?Control?繼承。)

      Closed

      關(guān)閉窗體時(shí)發(fā)生。

      Closing

      關(guān)閉窗體時(shí)發(fā)生。

      ContextMenuChanged

      當(dāng)?ContextMenu?屬性的值更改時(shí)發(fā)生。(從?Control?繼承。)

      ContextMenuStripChanged

      當(dāng)?ContextMenuStrip?屬性的值更改時(shí)發(fā)生。(從?Control?繼承。)

      ControlAdded

      在將新控件添加到?Control.ControlCollection?時(shí)發(fā)生。(從?Control?繼承。)

      ControlRemoved

      在從?Control.ControlCollection?移除控件時(shí)發(fā)生。(從?Control?繼承。)

      CursorChanged

      當(dāng)?Cursor?屬性的值更改時(shí)發(fā)生。(從?Control?繼承。)

      Deactivate

      當(dāng)窗體失去焦點(diǎn)并不再是活動(dòng)窗體時(shí)發(fā)生。

      Disposed

      當(dāng)通過調(diào)用?Dispose?方法釋放組件時(shí)發(fā)生。(從?Component?繼承。)

      DockChanged

      當(dāng)?Dock?屬性的值更改時(shí)發(fā)生。(從?Control?繼承。)

      DoubleClick

      在雙擊控件時(shí)發(fā)生。(從?Control?繼承。)

      DragDrop

      拖放操作完成時(shí)發(fā)生。(從?Control?繼承。)

      DragEnter

      在將對(duì)象拖入控件的邊界時(shí)發(fā)生。(從?Control?繼承。)

      DragLeave

      將對(duì)象拖出控件的邊界時(shí)發(fā)生。(從?Control?繼承。)

      DragOver

      在將對(duì)象拖到控件的邊界上發(fā)生。(從?Control?繼承。)

      EnabledChanged

      在?Enabled?屬性值更改后發(fā)生。(從?Control?繼承。)

      Enter

      進(jìn)入控件時(shí)發(fā)生。(從?Control?繼承。)

      FontChanged

      在?Font?屬性值更改時(shí)發(fā)生。(從?Control?繼承。)

      ForeColorChanged

      在?ForeColor?屬性值更改時(shí)發(fā)生。(從?Control?繼承。)

      FormClosed

      關(guān)閉窗體后發(fā)生。

      FormClosing

      關(guān)閉窗體前發(fā)生。

      GiveFeedback

      在執(zhí)行拖動(dòng)操作期間發(fā)生。(從?Control?繼承。)

      GotFocus

      在控件接收焦點(diǎn)時(shí)發(fā)生。(從?Control?繼承。)

      HandleCreated

      在為控件創(chuàng)建句柄時(shí)發(fā)生。(從?Control?繼承。)

      HandleDestroyed

      在控件的句柄處于銷毀過程中時(shí)發(fā)生。(從?Control?繼承。)

      HelpButtonClicked

      單擊“幫助”按鈕時(shí)發(fā)生。

      HelpRequested

      用戶請(qǐng)求控件幫助時(shí)發(fā)生。(從?Control?繼承。)

      ImeModeChanged

      在?ImeMode?屬性更改后發(fā)生。(從?Control?繼承。)

      InputLanguageChanged

      更改窗體的輸入語言后發(fā)生。

      InputLanguageChanging

      當(dāng)用戶嘗試更改窗體的輸入語言時(shí)發(fā)生。

      Invalidated

      控件的顯示要求重新繪制時(shí)發(fā)生。(從?Control?繼承。)

      KeyDown

      在控件有焦點(diǎn)的情況下按下鍵時(shí)發(fā)生。(從?Control?繼承。)

      KeyPress

      在控件有焦點(diǎn)的情況下字符、空格或退格鍵時(shí)發(fā)生。(從?Control?繼承。)

      KeyUp

      在控件有焦點(diǎn)的情況下釋放鍵時(shí)發(fā)生。(從?Control?繼承。)

      Layout

      在控件應(yīng)重新定位其子控件時(shí)發(fā)生。(從?Control?繼承。)

      Leave

      在輸入焦點(diǎn)離開控件時(shí)發(fā)生。(從?Control?繼承。)

      Load

      在第一次顯示窗體前發(fā)生。

      LocationChanged

      在?Location?屬性值更改后發(fā)生。(從?Control?繼承。)

      LostFocus

      在控件失去焦點(diǎn)時(shí)發(fā)生。(從?Control?繼承。)

      MarginChanged

      當(dāng)?Margin?屬性更改時(shí)發(fā)生。

      MaximizedBoundsChanged

      在?MaximizedBounds?屬性的值更改后發(fā)生。

      MaximumSizeChanged

      在?MaximumSize?屬性的值更改后發(fā)生。

      MdiChildActivate

      在多文檔界面 (MDI) 應(yīng)用程序內(nèi)激活或關(guān)閉 MDI 子窗體時(shí)發(fā)生。

      MenuComplete

      當(dāng)窗體菜單失去焦點(diǎn)時(shí)發(fā)生。

      MenuStart

      當(dāng)窗體菜單接收焦點(diǎn)時(shí)發(fā)生。

      MinimumSizeChanged

      在?MinimumSize?屬性的值更改后發(fā)生。

      MouseCaptureChanged

      當(dāng)控件失去鼠標(biāo)捕獲時(shí)發(fā)生。(從?Control?繼承。)

      MouseClick

      用鼠標(biāo)單擊控件時(shí)發(fā)生。(從?Control?繼承。)

      MouseDoubleClick

      用鼠標(biāo)雙擊控件時(shí)發(fā)生。(從?Control?繼承。)

      MouseDown

      當(dāng)鼠標(biāo)指針位于控件上并按下鼠標(biāo)鍵時(shí)發(fā)生。(從?Control?繼承。)

      MouseEnter

      在鼠標(biāo)指針進(jìn)入控件時(shí)發(fā)生。(從?Control?繼承。)

      MouseHover

      在鼠標(biāo)指針停放在控件上時(shí)發(fā)生。(從?Control?繼承。)

      MouseLeave

      在鼠標(biāo)指針離開控件時(shí)發(fā)生。(從?Control?繼承。)

      MouseMove

      在鼠標(biāo)指針移到控件上時(shí)發(fā)生。(從?Control?繼承。)

      MouseUp

      在鼠標(biāo)指針在控件上并釋放鼠標(biāo)鍵時(shí)發(fā)生。(從?Control?繼承。)

      MouseWheel

      在控件有焦點(diǎn)且鼠標(biāo)輪移動(dòng)時(shí)發(fā)生。(從?Control?繼承。)

      Move

      在移動(dòng)控件時(shí)發(fā)生。(從?Control?繼承。)

      PaddingChanged

      在控件空白區(qū)更改時(shí)發(fā)生。(從?Control?繼承。)

      Paint

      在重繪控件時(shí)發(fā)生。(從?Control?繼承。)

      ParentChanged

      在?Parent?屬性值更改時(shí)發(fā)生。(從?Control?繼承。)

      PreviewKeyDown

      在焦點(diǎn)位于此控件上的情況下,當(dāng)有按鍵動(dòng)作時(shí)發(fā)生(在?KeyDown?事件之前發(fā)生)。(從Control?繼承。)

      QueryAccessibilityHelp

      在?AccessibleObject?為輔助功能應(yīng)用程序提供幫助時(shí)發(fā)生。(從?Control?繼承。)

      QueryContinueDrag

      在拖放操作期間發(fā)生,并且允許拖動(dòng)源確定是否應(yīng)取消拖放操作。(從?Control?繼承。)

      RegionChanged

      當(dāng)?Region?屬性的值更改時(shí)發(fā)生。(從?Control?繼承。)

      Resize

      在調(diào)整控件大小時(shí)發(fā)生。(從?Control?繼承。)

      ResizeBegin

      窗體進(jìn)入大小調(diào)整模式時(shí)發(fā)生。

      ResizeEnd

      窗體退出大小調(diào)整模式時(shí)發(fā)生。

      RightToLeftChanged

      在?RightToLeft?屬性值更改時(shí)發(fā)生。(從?Control?繼承。)

      RightToLeftLayoutChanged

      更改?RightToLeftLayout?屬性值之后發(fā)生。

      Scroll

      用戶或代碼滾動(dòng)工作區(qū)時(shí)發(fā)生。(從?ScrollableControl?繼承。)

      Shown

      只要窗體是首次顯示就發(fā)生。

      SizeChanged

      在?Size?屬性值更改時(shí)發(fā)生。(從?Control?繼承。)

      StyleChanged

      在控件樣式更改時(shí)發(fā)生。(從?Control?繼承。)

      SystemColorsChanged

      系統(tǒng)顏色更改時(shí)發(fā)生。(從?Control?繼承。)

      TabIndexChanged

      此 API 支持 產(chǎn)品 基礎(chǔ)結(jié)構(gòu),不能在代碼中直接使用。?當(dāng)?TabIndex?屬性的值更改時(shí)發(fā)生。

      TabStopChanged

      當(dāng)?TabStop?屬性更改時(shí)發(fā)生。

      TextChanged

      在?Text?屬性值更改時(shí)發(fā)生。(從?Control?繼承。)

      Validated

      在控件完成驗(yàn)證時(shí)發(fā)生。(從?Control?繼承。)

      Validating

      在控件驗(yàn)證時(shí)發(fā)生。(從?Control?繼承。)

      VisibleChanged

      在?Visible?屬性值更改時(shí)發(fā)生。(從?Control?繼承。)

      VB.NET 事件的含義

      TextBox1_TextChanged() 'TextBox1.text屬性改變時(shí)發(fā)生

      ?Label1_Click() 'Label1被鼠標(biāo)點(diǎn)擊時(shí)發(fā)生

      ?MenuItem1_Click() 'MenuItem1被鼠標(biāo)點(diǎn)擊時(shí)發(fā)生

      ?Label1_MouseDown() '鼠標(biāo)左鍵在Label1上按下時(shí)發(fā)生

      ?Label1_DoubleClick() '有點(diǎn)難我也不太清楚,在MSDN上查了下:

      雙擊操作由用戶操作系統(tǒng)的鼠標(biāo)設(shè)置確定。用戶可以設(shè)置兩次單擊鼠標(biāo)按鈕之間的時(shí)間以便將這兩次單擊認(rèn)為是雙擊而不是兩次單擊。每當(dāng)雙擊控件時(shí),就會(huì)引發(fā) Click 事件。例如,如果您有 Form 的 Click 和 DoubleClick 事件的事件處理程序,則當(dāng)雙擊該窗體并同時(shí)調(diào)用這兩個(gè)方法時(shí),會(huì)引發(fā) Click 和 DoubleClick 事件。如果雙擊一個(gè)控件并且該控件不支持 DoubleClick 事件,則 Click 事件可能被引發(fā)兩次。

      Label1_MouseUp() '鼠標(biāo)左鍵在Label1上放開時(shí)發(fā)生,一般與Label1_MouseDown()搭配使用

      ?TextBox2_MouseMove() '鼠標(biāo)停留在TextBox2上時(shí)發(fā)生

      ?Form1_load() '加載窗體時(shí)發(fā)生

      ?Form1_click() '點(diǎn)擊窗體時(shí)發(fā)生

      ?Form1_Resize() '窗體調(diào)整大小后發(fā)生

      Form1_KeyPress() '當(dāng)窗體有焦點(diǎn)鍵盤有操作時(shí)發(fā)生

      ?Form1_KeyDown() '當(dāng)窗體具有焦點(diǎn)并鍵盤有按鍵按下時(shí)發(fā)生

      ?Form1_KeyUp() '當(dāng)窗體焦點(diǎn)并鍵盤有按鍵放開時(shí)發(fā)生


      名稱欄目:關(guān)于vb點(diǎn)虐 事件說明的信息
      本文地址:http://www.ef60e0e.cn/article/ddchgpo.html
      99热在线精品一区二区三区_国产伦精品一区二区三区女破破_亚洲一区二区三区无码_精品国产欧美日韩另类一区
      1. <ul id="0c1fb"></ul>

        <noscript id="0c1fb"><video id="0c1fb"></video></noscript>
        <noscript id="0c1fb"><listing id="0c1fb"><thead id="0c1fb"></thead></listing></noscript>

        湄潭县| 叙永县| 黔东| 龙川县| 威海市| 西青区| 清流县| 司法| 白银市| 益阳市| 西林县| 游戏| 崇义县| 青河县| 洛阳市| 九江市| 桦南县| 秦安县| 祥云县| 和静县| 永宁县| 吐鲁番市| 甘泉县| 洪雅县| 射阳县| 浦东新区| 隆德县| 扎囊县| 庆安县| 安庆市| 抚州市| 曲水县| 大英县| 安溪县| 湘西| 桂阳县| 辉南县| 喀什市| 西青区| 平罗县| 新竹县|