|
お初です。
自分の作ったコントロールの簡易版ですが、こんなんでどうでしょう?
ListBoxを変更すれば他のコントロールも乗せれますよ。
Public Class DropDownTextBox
Inherits TextBox
Private WithEvents ListBox1 As New ListBox
Private ToolStripDropDown1 As New ToolStripDropDown
Public Sub New()
Dim ToolStripControlHost1 As New ToolStripControlHost(ListBox1)
ToolStripControlHost1.AutoSize = False
ToolStripControlHost1.Margin = New Padding(0)
ToolStripDropDown1.DropShadowEnabled = False
ToolStripDropDown1.AutoSize = True
ToolStripDropDown1.Padding = New Padding(0)
ToolStripDropDown1.Items.Add(ToolStripControlHost1)
End Sub
Public ReadOnly Property Items() As ListBox.ObjectCollection
Get
Return ListBox1.Items
End Get
End Property
Protected Overrides Sub OnKeyDown(ByVal e As System.Windows.Forms.KeyEventArgs)
Select Case e.KeyCode
Case Keys.F1
ListBox1.Height = ListBox1.Items.Count * (ListBox1.ItemHeight + 1)
ToolStripDropDown1.Show(Me, -2, Me.Height - 3)
End Select
MyBase.OnKeyDown(e)
End Sub
Private Sub ListBox1_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListBox1.MouseClick
Me.Text = ListBox1.SelectedItem.ToString
ToolStripDropDown1.Hide()
End Sub
End Class
|