40 lines
1.1 KiB
VB.net
40 lines
1.1 KiB
VB.net
Imports System.ComponentModel
|
|
|
|
Public Class MyComboBox
|
|
Inherits System.Windows.Forms.ComboBox
|
|
|
|
Public Sub New()
|
|
End Sub
|
|
|
|
Sub fillWithMyListItem(l As List(Of MyListItem))
|
|
MyBase.Items.Clear()
|
|
For Each i In l : MyBase.Items.Add(i) : Next
|
|
End Sub
|
|
Sub fillWithSQL(sql As String, Optional showValueInText As Boolean = True, Optional conn As String = "DISPO")
|
|
fillWithMyListItem((New cOptionenDAL).loadCboBySqlWithListItem(sql, showValueInText, conn))
|
|
End Sub
|
|
|
|
Public Property _value As String
|
|
Get
|
|
Return getValueOfItem()
|
|
End Get
|
|
Set(v As String)
|
|
changeItem(v)
|
|
End Set
|
|
End Property
|
|
|
|
Sub changeItem(v)
|
|
For Each i In MyBase.Items
|
|
If DirectCast(i, MyListItem).Value = v Then
|
|
MyBase.SelectedItem = i : Exit Sub
|
|
End If
|
|
Next
|
|
End Sub
|
|
|
|
Function getValueOfItem() As String
|
|
Try : Return DirectCast(MyBase.SelectedItem, MyListItem).Value : Catch : End Try
|
|
Return ""
|
|
End Function
|
|
End Class
|
|
|