You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
349 lines
11 KiB
349 lines
11 KiB
Imports System.ComponentModel
|
|
Imports System.Windows.Forms
|
|
Imports System.Drawing
|
|
|
|
Namespace Controls
|
|
|
|
< _
|
|
ToolboxBitmap(GetType(System.Windows.Forms.ComboBox)), _
|
|
DefaultEvent("AfterSelect") _
|
|
> Public Class ComboBoxTree
|
|
Inherits System.Windows.Forms.UserControl
|
|
|
|
#Region " Windows Form Designer generated code "
|
|
|
|
Public Sub New()
|
|
MyBase.New()
|
|
|
|
'This call is required by the Windows Form Designer.
|
|
InitializeComponent()
|
|
|
|
'Add any initialization after the InitializeComponent() call
|
|
|
|
End Sub
|
|
|
|
'UserControl overrides dispose to clean up the component list.
|
|
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
|
|
If disposing Then
|
|
If Not (components Is Nothing) Then
|
|
components.Dispose()
|
|
End If
|
|
End If
|
|
MyBase.Dispose(disposing)
|
|
End Sub
|
|
|
|
'Required by the Windows Form Designer
|
|
Private components As System.ComponentModel.IContainer
|
|
|
|
'NOTE: The following procedure is required by the Windows Form Designer
|
|
'It can be modified using the Windows Form Designer.
|
|
'Do not modify it using the code editor.
|
|
Friend WithEvents ComboBox As ComboBoxTree_ComboBox
|
|
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
|
|
Me.ComboBox = New ComboBoxTree_ComboBox
|
|
Me.SuspendLayout()
|
|
'
|
|
'ComboBox
|
|
'
|
|
Me.ComboBox.Dock = System.Windows.Forms.DockStyle.Top
|
|
Me.ComboBox.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed
|
|
Me.ComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
|
|
Me.ComboBox.ItemHeight = 16
|
|
Me.ComboBox.Location = New System.Drawing.Point(0, 0)
|
|
Me.ComboBox.Name = "ComboBox"
|
|
Me.ComboBox.SelectedItem = Nothing
|
|
Me.ComboBox.Size = New System.Drawing.Size(384, 22)
|
|
Me.ComboBox.TabIndex = 0
|
|
'
|
|
'ComboBoxTree
|
|
'
|
|
Me.BackColor = System.Drawing.SystemColors.Window
|
|
Me.Controls.Add(Me.ComboBox)
|
|
Me.Name = "ComboBoxTree"
|
|
Me.Size = New System.Drawing.Size(384, 72)
|
|
Me.ResumeLayout(False)
|
|
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
Public Event DropDown(ByVal sender As Object)
|
|
Public Event CloseUp(ByVal sender As Object)
|
|
Public Event BeforeSelect(ByVal sender As Object, ByVal Node As TreeNode, ByRef Cancel As Boolean)
|
|
Public Event AfterSelect(ByVal sender As Object)
|
|
|
|
Private p_DropDownWidth As Integer = -1
|
|
|
|
#Region " Standard Public Properties "
|
|
|
|
Public Shadows Property Size() As Drawing.Size
|
|
Get
|
|
Return MyBase.Size
|
|
End Get
|
|
Set(ByVal Value As Drawing.Size)
|
|
MyBase.Size = New Size(Value.Width, Me.ComboBox.Height)
|
|
If p_DropDownWidth <= 0 Then Me.ComboBox.TreeView.Width = Value.Width
|
|
End Set
|
|
End Property
|
|
|
|
Public Shadows Property Height() As Integer
|
|
Get
|
|
Return MyBase.Height
|
|
End Get
|
|
Set(ByVal Value As Integer)
|
|
Me.ComboBox.Height = Value
|
|
MyBase.Height = Me.ComboBox.Height
|
|
End Set
|
|
End Property
|
|
|
|
Public Shadows Property Width() As Integer
|
|
Get
|
|
Return MyBase.Width
|
|
End Get
|
|
Set(ByVal Value As Integer)
|
|
MyBase.Width = Value
|
|
If p_DropDownWidth <= 0 Then Me.ComboBox.TreeView.Width = Value
|
|
End Set
|
|
End Property
|
|
|
|
< _
|
|
DefaultValue(GetType(Color), "Window") _
|
|
> Public Shadows Property BackColor() As System.Drawing.Color
|
|
Get
|
|
Return MyBase.BackColor
|
|
End Get
|
|
Set(ByVal Value As System.Drawing.Color)
|
|
MyBase.BackColor = Value
|
|
Me.ComboBox.BackColor = Value
|
|
End Set
|
|
End Property
|
|
|
|
Public Shadows Property ForeColor() As System.Drawing.Color
|
|
Get
|
|
Return MyBase.ForeColor
|
|
End Get
|
|
Set(ByVal Value As System.Drawing.Color)
|
|
MyBase.ForeColor = Value
|
|
Me.ComboBox.ForeColor = Value
|
|
End Set
|
|
End Property
|
|
|
|
< _
|
|
Browsable(False) _
|
|
> Public Shadows Property BackgroundImage() As System.Drawing.Image
|
|
Get
|
|
Return MyBase.BackgroundImage
|
|
End Get
|
|
Set(ByVal Value As System.Drawing.Image)
|
|
MyBase.BackgroundImage = Value
|
|
Me.ComboBox.TreeView.BackgroundImage = Value
|
|
End Set
|
|
End Property
|
|
|
|
Public Shadows Property Font() As System.Drawing.Font
|
|
Get
|
|
Return MyBase.Font
|
|
End Get
|
|
Set(ByVal Value As System.Drawing.Font)
|
|
MyBase.Font = Value
|
|
Me.ComboBox.Font = Value
|
|
End Set
|
|
End Property
|
|
|
|
Public Shadows Property Enabled() As Boolean
|
|
Get
|
|
Return MyBase.Enabled
|
|
End Get
|
|
Set(ByVal Value As Boolean)
|
|
MyBase.Enabled = Value
|
|
Me.ComboBox.Enabled = Value
|
|
End Set
|
|
End Property
|
|
|
|
Public Shadows Property ContextMenu() As System.Windows.Forms.ContextMenu
|
|
Get
|
|
Return MyBase.ContextMenu
|
|
End Get
|
|
Set(ByVal Value As System.Windows.Forms.ContextMenu)
|
|
MyBase.ContextMenu = Value
|
|
Me.ComboBox.ContextMenu = Value
|
|
End Set
|
|
End Property
|
|
|
|
#End Region
|
|
|
|
#Region " Particular Public Properties "
|
|
|
|
< _
|
|
Browsable(False) _
|
|
> Public Property SelectedNode() As TreeNode
|
|
Get
|
|
Return Me.ComboBox.SelectedItem
|
|
End Get
|
|
Set(ByVal Value As TreeNode)
|
|
Me.ComboBox.SelectedItem = Value
|
|
End Set
|
|
End Property
|
|
|
|
< _
|
|
Category("Behavior"), _
|
|
DefaultValue(16) _
|
|
> Public Property ItemHeight() As Integer
|
|
Get
|
|
Return Me.ComboBox.ItemHeight
|
|
End Get
|
|
Set(ByVal Value As Integer)
|
|
If Value <= 0 Then Value = 16
|
|
Me.ComboBox.ItemHeight = Value
|
|
Me.Height = Me.ComboBox.Height
|
|
Me.Invalidate()
|
|
End Set
|
|
End Property
|
|
|
|
< _
|
|
Category("Behavior"), _
|
|
DefaultValue(0) _
|
|
> Public Property ImageIndex() As Integer
|
|
Get
|
|
Return Me.ComboBox.TreeView.ImageIndex
|
|
End Get
|
|
Set(ByVal Value As Integer)
|
|
Me.ComboBox.TreeView.ImageIndex = Value
|
|
End Set
|
|
End Property
|
|
|
|
< _
|
|
Category("Behavior"), _
|
|
DefaultValue(1) _
|
|
> Public Property SelectedImageIndex() As Integer
|
|
Get
|
|
Return Me.ComboBox.TreeView.SelectedImageIndex
|
|
End Get
|
|
Set(ByVal Value As Integer)
|
|
Me.ComboBox.TreeView.SelectedImageIndex = Value
|
|
End Set
|
|
End Property
|
|
|
|
< _
|
|
Category("Behavior") _
|
|
> Public Property ImageList() As ImageList
|
|
Get
|
|
Return Me.ComboBox.TreeView.ImageList
|
|
End Get
|
|
Set(ByVal Value As ImageList)
|
|
Me.ComboBox.TreeView.ImageList = Value
|
|
End Set
|
|
End Property
|
|
|
|
< _
|
|
Category("Behavior"), _
|
|
DefaultValue(-1) _
|
|
> Public Property DropDownWidth() As Integer
|
|
Get
|
|
Return p_DropDownWidth
|
|
End Get
|
|
Set(ByVal Value As Integer)
|
|
If Value <= 0 Then
|
|
p_DropDownWidth = -1
|
|
Me.ComboBox.TreeView.Width = Me.Width
|
|
Else
|
|
p_DropDownWidth = Value
|
|
Me.ComboBox.TreeView.Width = p_DropDownWidth
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
< _
|
|
Category("Behavior"), _
|
|
DefaultValue(194) _
|
|
> Public Property DropDownHeight() As Integer
|
|
Get
|
|
Return Me.ComboBox.TreeView.Height
|
|
End Get
|
|
Set(ByVal Value As Integer)
|
|
If Value > 0 Then
|
|
Me.ComboBox.TreeView.Height = Value
|
|
Else
|
|
Me.ComboBox.TreeView.Height = 194
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
<Browsable(False), _
|
|
DefaultValue(False) _
|
|
> Public Property DroppedDown() As Boolean
|
|
Get
|
|
Return Me.ComboBox.DroppedDown
|
|
End Get
|
|
Set(ByVal Value As Boolean)
|
|
Me.ComboBox.DroppedDown = Value
|
|
End Set
|
|
End Property
|
|
|
|
#End Region
|
|
|
|
#Region " Public Methods "
|
|
|
|
Public Function TreeView() As TreeView
|
|
Return Me.ComboBox.TreeView
|
|
End Function
|
|
|
|
#End Region
|
|
|
|
#Region " Private Methods "
|
|
|
|
Private Sub UserControl_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Resize
|
|
Me.Height = Me.ComboBox.Height
|
|
Me.ComboBox.TreeView.Left = Me.Left
|
|
Me.ComboBox.TreeView.Top = Me.Top + Me.Height
|
|
If p_DropDownWidth <= 0 Then Me.ComboBox.TreeView.Width = Me.Width
|
|
End Sub
|
|
|
|
Private Sub ComboBox_DropDown() Handles ComboBox.DropDown
|
|
RaiseEvent DropDown(Me)
|
|
End Sub
|
|
|
|
Protected Overrides Sub OnParentChanged(ByVal e As System.EventArgs)
|
|
Me.ComboBox.TreeView.Parent = Me.Parent
|
|
End Sub
|
|
|
|
Private Sub ComboBox_AfterSelect() Handles ComboBox.AfterSelect
|
|
RaiseEvent AfterSelect(Me)
|
|
End Sub
|
|
|
|
Private Sub ComboBox_BeforeSelect(ByVal Node As System.Windows.Forms.TreeNode, ByRef Cancel As Boolean) Handles ComboBox.BeforeSelect
|
|
RaiseEvent BeforeSelect(Me, Node, Cancel)
|
|
End Sub
|
|
|
|
Private Sub ComboBox_CloseUp() Handles ComboBox.CloseUp
|
|
RaiseEvent CloseUp(Me)
|
|
End Sub
|
|
|
|
Protected Overrides Sub OnCreateControl()
|
|
MyBase.BackColor = System.Drawing.SystemColors.Window
|
|
Me.ComboBox.BackColor = MyBase.BackColor
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
Public Class SelectEventArgs
|
|
Public Node As TreeNode
|
|
Public Cancel As Boolean
|
|
|
|
Public Sub New(ByVal Node As TreeNode)
|
|
Me.Node = Node
|
|
Me.Cancel = False
|
|
End Sub
|
|
End Class
|
|
|
|
Private Sub ComboBoxTree_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
|
|
|
|
End Sub
|
|
|
|
Private Sub ComboBoxTree_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles MyBase.KeyPress
|
|
|
|
End Sub
|
|
End Class
|
|
|
|
End Namespace
|