Imports System.ComponentModel
Imports System.Drawing.Design
Imports System.Windows.Forms.Design
Public Class TestTextBox
Inherits TextBox
<Browsable(True)>
<Editor(GetType(Editor), GetType(UITypeEditor))>
<DefaultValue("Hello")>
Public Property MyProperty As String
Private Class Editor
Inherits UITypeEditor
Private mSvc As IWindowsFormsEditorService
Public Overrides Function GetEditStyle(context As ITypeDescriptorContext) As UITypeEditorEditStyle
Return UITypeEditorEditStyle.DropDown
End Function
Public Overrides Function EditValue(context As ITypeDescriptorContext, provider As IServiceProvider, value As Object) As Object
mSvc = CType(provider.GetService(GetType(IWindowsFormsEditorService)), IWindowsFormsEditorService)
Dim lb As New ListBox()
For Each value In {"Hello", "Whats", "Happening"}
lb.Items.Add(value)
Next
If value IsNot Nothing Then
lb.SelectedItem = value
End If
mSvc.DropDownControl(lb)
value = DirectCast(lb.SelectedItem, String)
Return value
End Function
End Class
End Class
聽起來好像你是一個組合框不是一個TextBox之後。這裏有很多在線教程。谷歌的'vb.net如何從數據庫中填充組合框' – FloatingKiwi
感謝FloatingKiwi爲您的重播 –
,但我要做一個自定義用戶控件,並添加一些屬性,我需要的是添加一個下拉屬性列表讓我們用戶從列表中選擇值 –