网站公告列表

  没有公告

加入收藏
设为首页
在线投稿

您现在的位置: IT知识网 >> IT知识 >> 程序设计 >> 汇编语言 >> 文章正文

 

  DotNET WinForm FAQ 16个(下)         

DotNET WinForm FAQ 16个(下)
作者:佚名 文章来源:不详 点击数: 更新时间:2006-12-1 17:18:03
bsp;   'TODO: Add any initialization after the InitializeComponent() call

       

        'this form isn't used directly so hide it immediately

        Me.Hide()

       

        'setup the tray icon

        Initializenotifyicon()

    End Sub

   

    Private Sub Initializenotifyicon()

        'setup the default icon

        notifyicon = New System.Windows.Forms.NotifyIcon()

        NotifyIcon.Icon = mIconA

        NotifyIcon.Text = "Right Click for the menu"

        NotifyIcon.Visible = True

        mIconDisplayed = True

 

        'Insert all MenuItem objects into an array and add them to

        'the context menu simultaneously

        Dim mnuItms(3) As MenuItem

        mnuItms(0) = New MenuItem("Show Form...", New EventHandler(AddressOf Me.ShowFormSelect))

        mnuItms(0).DefaultItem = True

        mnuItms(1) = New MenuItem("Toggle Image", New EventHandler(AddressOf Me.ToggleImageSelect))

        mnuItms(2) = New MenuItem("-")

        mnuItms(3) = New MenuItem("Exit", New EventHandler(AddressOf Me.ExitSelect))

        Dim notifyiconMnu As ContextMenu = New ContextMenu(mnuItms)

        notifyicon.ContextMenu = notifyiconMnu

    End Sub

 

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

        'Display the settings dialog

        Dim SettingsForm As New SettingsForm()

        SettingsForm.ShowDialog()

 

    End Sub

 

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

        'called when the user selects the 'Toggle Image' context menu

 

        'determine which icon is currently visible and switch it

        If mIconDisplayed Then

            'called when the user selects the 'Show Form' context menu

            NotifyIcon.Icon = mIconB

            NotifyIcon.Text = "Sad"

            mIconDisplayed = False

        Else

            NotifyIcon.Icon = mIconA

            NotifyIcon.Text = "Happy"

            mIconDisplayed = True

        End If

 

    End Sub

 

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

        'called when the user selects the 'Exit' context menu

 

        'hide the tray icon

        NotifyIcon.Visible = False

 

        'close up

        Me.Close()

    End Sub

 

    'Form overrides dispose to clean up the component list.

    Public Overloads Overrides Sub Dispose()

        MyBase.Dispose()

        components.Dispose()

    End Sub

    图标文件你自己准备了,如果成功你可以看到有关NotifyIcond的各种功能了。

 

13.     如何修改控制窗体的尺寸和长宽尺寸.

主要是修改Winform的Size, Width 和Height属性。同样它们都是可以在设计和运行时刻进行修改和设置。

Form1.Size = New System.Drawing.Size(100, 100) ( VB.NET )

Form1.Width += 100  (VB.NET )

Form1.Height -= 20  (VB.NET )

 

14.     如何建立一个Windows Explorer风格的窗体.

1.建立一个新的Windows Application

2.从Toolbox窗口拖一个TreeView控件、、一个Splitterk控件、一个ListView控件,分别在属性窗口中设置TreeView的Dock属性为::Left;设置ListView控件的Dock属性为:Fill

3: F5 运行

 

上一页  [1] [2] [3] 下一页

文章录入:bolang    责任编辑:bolang 
  • 上一篇文章:

  • 下一篇文章:
  • 【字体: 】【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
    最 新 热 门
    相 关 文 章
    OSPF Troubleshooting 实
    采用基于Guard和Detecto
    Cisco works windows 5.
    CISCO学习问题之ip forw
    六、PSTN,CISCO路由器配
    Cisco 路由器如何防止 D
    Cisco路由器由Windows20
    Cisco路由器由Windows20
    Cisco路由器如何防止DDo
    Cisco路由器由Windows 2
     
      网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)
    Copyright© ITZS.NET All Rights Reserved
    QQ:272895858   ICP备案编号:吉ICP备07000044号
    IT知识网 站长:博浪