⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wroxtoolbarbuttonsform.vb

📁 ASP.NET服务器控件高级编程电子书
💻 VB
字号:
Imports System
Imports System.Drawing
Imports System.Collections
Imports System.ComponentModel
Imports System.Windows.Forms

Namespace WroxDesignVB.Design

    '/ <summary>
    '/ Summary description for WroxToolBarButtons.
    '/ </summary>
    Public Class WroxToolBarButtonsForm : Inherits System.Windows.Forms.Form

        Private btnResult As System.Windows.Forms.Panel
        Private panel1 As System.Windows.Forms.Panel
        Private WithEvents lstButtons As System.Windows.Forms.ListBox
        Private WithEvents btnAccept As System.Windows.Forms.Button
        Private WithEvents btnCancel As System.Windows.Forms.Button
        Private WithEvents btnAdd As System.Windows.Forms.Button
        Private WithEvents btnRemove As System.Windows.Forms.Button
        Private WithEvents btnUp As System.Windows.Forms.Button
        Private WithEvents btnDown As System.Windows.Forms.Button
        '/ <summary>
        '/ Required designer variable.
        '/ </summary>
        Private components As System.ComponentModel.Container = Nothing
        Private propGrid As System.Windows.Forms.PropertyGrid

        Private _buttons As ArrayList

        Public Sub New(ByVal Buttons As ArrayList)
            InitializeComponent()
            _buttons = Buttons
        End Sub

        '/ <summary>
        '/ Clean up any resources being used.
        '/ </summary>
        Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)

            If (Disposing) Then _
    If Not (components Is Nothing) Then _
                    components.Dispose()
            MyBase.Dispose(disposing)
        End Sub

#Region "Windows Form Designer generated code"
        '/ <summary>
        '/ Required method for Designer support - do not modify
        '/ the contents of me method with the code editor.
        '/ </summary>
        Private Sub InitializeComponent()

            Me.btnAdd = New System.Windows.Forms.Button()
            Me.btnRemove = New System.Windows.Forms.Button()
            Me.btnAccept = New System.Windows.Forms.Button()
            Me.btnCancel = New System.Windows.Forms.Button()
            Me.btnResult = New System.Windows.Forms.Panel()
            Me.panel1 = New System.Windows.Forms.Panel()
            Me.btnDown = New System.Windows.Forms.Button()
            Me.btnUp = New System.Windows.Forms.Button()
            Me.lstButtons = New System.Windows.Forms.ListBox()
            Me.propGrid = New System.Windows.Forms.PropertyGrid()
            Me.btnResult.SuspendLayout()
            Me.panel1.SuspendLayout()
            Me.SuspendLayout()
            ' 
            ' btnAdd
            ' 
            Me.btnAdd.Anchor = (System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Left)
            Me.btnAdd.FlatStyle = System.Windows.Forms.FlatStyle.Flat
            Me.btnAdd.Location = New System.Drawing.Point(4, 276)
            Me.btnAdd.Name = "btnAdd"
            Me.btnAdd.Size = New System.Drawing.Size(56, 20)
            Me.btnAdd.TabIndex = 1
            Me.btnAdd.Text = "Add"
            ' 
            ' btnRemove
            ' 
            Me.btnRemove.Anchor = (System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Left)
            Me.btnRemove.FlatStyle = System.Windows.Forms.FlatStyle.Flat
            Me.btnRemove.Location = New System.Drawing.Point(88, 276)
            Me.btnRemove.Name = "btnRemove"
            Me.btnRemove.Size = New System.Drawing.Size(56, 20)
            Me.btnRemove.TabIndex = 2
            Me.btnRemove.Text = "Remove"
            ' 
            ' btnAccept
            ' 
            Me.btnAccept.Anchor = (System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right)
            Me.btnAccept.DialogResult = System.Windows.Forms.DialogResult.OK
            Me.btnAccept.FlatStyle = System.Windows.Forms.FlatStyle.Flat
            Me.btnAccept.Location = New System.Drawing.Point(308, 4)
            Me.btnAccept.Name = "btnAccept"
            Me.btnAccept.Size = New System.Drawing.Size(60, 20)
            Me.btnAccept.TabIndex = 0
            Me.btnAccept.Text = "Accept"
            ' 
            ' btnCancel
            ' 
            Me.btnCancel.Anchor = (System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right)
            Me.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel
            Me.btnCancel.FlatStyle = System.Windows.Forms.FlatStyle.Flat
            Me.btnCancel.Location = New System.Drawing.Point(376, 4)
            Me.btnCancel.Name = "btnCancel"
            Me.btnCancel.Size = New System.Drawing.Size(64, 20)
            Me.btnCancel.TabIndex = 1
            Me.btnCancel.Text = "Cancel"
            ' 
            ' btnResult
            ' 
            Me.btnResult.Controls.AddRange(New System.Windows.Forms.Control() { _
                              Me.btnCancel, _
                              Me.btnAccept})
            Me.btnResult.Dock = System.Windows.Forms.DockStyle.Bottom
            Me.btnResult.Location = New System.Drawing.Point(0, 304)
            Me.btnResult.Name = "btnResult"
            Me.btnResult.Size = New System.Drawing.Size(444, 28)
            Me.btnResult.TabIndex = 1
            ' 
            ' panel1
            ' 
            Me.panel1.Controls.AddRange(New System.Windows.Forms.Control() { _
                              Me.btnDown, _
                              Me.btnUp, _
                              Me.btnRemove, _
                              Me.btnAdd, _
                              Me.lstButtons})
            Me.panel1.Dock = System.Windows.Forms.DockStyle.Left
            Me.panel1.Name = "panel1"
            Me.panel1.Size = New System.Drawing.Size(200, 304)
            Me.panel1.TabIndex = 3
            ' 
            ' btnDown
            ' 
            Me.btnDown.FlatStyle = System.Windows.Forms.FlatStyle.Flat
            Me.btnDown.Location = New System.Drawing.Point(152, 28)
            Me.btnDown.Name = "btnDown"
            Me.btnDown.Size = New System.Drawing.Size(44, 20)
            Me.btnDown.TabIndex = 4
            Me.btnDown.Text = "Down"
            ' 
            ' btnUp
            ' 
            Me.btnUp.FlatStyle = System.Windows.Forms.FlatStyle.Flat
            Me.btnUp.Location = New System.Drawing.Point(152, 4)
            Me.btnUp.Name = "btnUp"
            Me.btnUp.Size = New System.Drawing.Size(44, 20)
            Me.btnUp.TabIndex = 3
            Me.btnUp.Text = "Up"
            ' 
            ' lstButtons
            ' 
            Me.lstButtons.Anchor = (System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom _
             Or System.Windows.Forms.AnchorStyles.Left)
            Me.lstButtons.Name = "lstButtons"
            Me.lstButtons.Size = New System.Drawing.Size(148, 264)
            Me.lstButtons.TabIndex = 0
            ' 
            ' propGrid
            ' 
            Me.propGrid.CommandsVisibleIfAvailable = True
            Me.propGrid.Dock = System.Windows.Forms.DockStyle.Fill
            Me.propGrid.LargeButtons = False
            Me.propGrid.LineColor = System.Drawing.SystemColors.ScrollBar
            Me.propGrid.Location = New System.Drawing.Point(200, 0)
            Me.propGrid.Name = "propGrid"
            Me.propGrid.Size = New System.Drawing.Size(244, 304)
            Me.propGrid.TabIndex = 2
            Me.propGrid.Text = "WroxButton properties"
            Me.propGrid.ViewBackColor = System.Drawing.SystemColors.Window
            Me.propGrid.ViewForeColor = System.Drawing.SystemColors.WindowText
            ' 
            ' WroxToolBarButtonsForm
            ' 
            Me.AcceptButton = Me.btnAccept
            Me.AutoScaleBaseSize = New System.Drawing.Size(5, 14)
            Me.CancelButton = Me.btnCancel
            Me.ClientSize = New System.Drawing.Size(444, 332)
            Me.ControlBox = False
            Me.Controls.AddRange(New System.Windows.Forms.Control() { _
                             Me.propGrid, _
                             Me.panel1, _
                             Me.btnResult})
            Me.Font = New System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, System.Byte))
            Me.Name = "WroxToolBarButtonsForm"
            Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
            Me.Text = "WroxToolBar Button Collection Editor"
            Me.btnResult.ResumeLayout(False)
            Me.panel1.ResumeLayout(False)
            Me.ResumeLayout(False)
        End Sub

#End Region

        Private Sub lstButtons_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles lstButtons.SelectedIndexChanged
            propGrid.SelectedObject = lstButtons.SelectedItem
        End Sub

        Private Sub WroxToolBarButtons_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Dim obj As Object
            For Each obj In _buttons
                lstButtons.Items.Add(obj)
            Next
        End Sub

        Private Sub btnAdd_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnAdd.Click
            Dim i As Integer = lstButtons.Items.Add(New WroxButton())
            lstButtons.SelectedIndex = i
        End Sub

        Private Sub btnRemove_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnRemove.Click
            lstButtons.Items.Remove(lstButtons.SelectedItem)
            propGrid.SelectedObject = Nothing
        End Sub

        Private Sub btnUp_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnUp.Click
            Dim selected As Object = lstButtons.SelectedItem
            Dim idx As Integer = lstButtons.SelectedIndex
            If Not (selected Is Nothing) Then
                lstButtons.Items.Remove(selected)
                lstButtons.Items.Insert(idx - 1, selected)
            End If
        End Sub

        Private Sub btnDown_Click(ByVal sender As Object, ByVal e As System.EventArgs)
            Dim selected As Object = lstButtons.SelectedItem
            Dim idx As Integer = lstButtons.SelectedIndex
            If Not (selected Is Nothing) Then
                lstButtons.Items.Remove(selected)
                lstButtons.Items.Insert(idx, selected)
            End If
        End Sub

        Public ReadOnly Property Buttons() As ArrayList
            Get
                Return New ArrayList(lstButtons.Items)
            End Get
        End Property

    End Class
End Namespace





⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -