Expand|Select|Wrap|Line Numbers
- Public Class ComboControl : Inherits System.Windows.Forms.ComboBox
- Private _CodeDescriptions As New Dictionary(Of String, String)
- Private _DescriptionCodes As New Dictionary(Of String, String)
- Private _AllowNone As Boolean
- Private _AllowAny As Boolean
- Private _ContextFlag As String
- Public Sub Clear()
- _CodeDescriptions.Clear()
- _DescriptionCodes.Clear()
- Me.Items.Clear()
- End Sub
- Public Property AllowAny() As Boolean
- Get
- AllowAny = _AllowAny
- End Get
- Set(ByVal value As Boolean)
- _AllowAny = value
- End Set
- End Property
- Public Property AllowNone() As Boolean
- Get
- AllowNone = _AllowNone
- End Get
- Set(ByVal value As Boolean)
- _AllowNone = value
- End Set
- End Property
- Public Property ContextFlag() As String
- Get
- ContextFlag = _ContextFlag
- End Get
- Set(ByVal value As String)
- _ContextFlag = value
- End Set
- End Property
- Public Sub Add(ByVal Code As String, ByVal Description As String)
- If _CodeDescriptions.Count = 0 And AllowNone Then
- Me.Items.Add("<None>")
- End If
- If _CodeDescriptions.Count = 0 And AllowAny Then
- Me.Items.Add("<Any>")
- End If
- Me.Items.Add(Description)
- _CodeDescriptions.Add(Code, Description)
- If Not _DescriptionCodes.ContainsKey(Description) Then ' suppress duplicates
- _DescriptionCodes.Add(Description, Code)
- End If
- End Sub
- Public Property Code() As String
- Get
- If Me.SelectedItem IsNot Nothing AndAlso Me.SelectedItem.ToString <> "" Then
- If _DescriptionCodes.ContainsKey(Me.SelectedItem.ToString) Then
- Return (_DescriptionCodes(Me.SelectedItem.ToString))
- Else
- Return ""
- End If
- Else
- Return ""
- End If
- End Get
- Set(ByVal value As String)
- Dim SelectedItem As String = ""
- If value <> "" Then
- If _CodeDescriptions.TryGetValue(value, SelectedItem) Then
- Me.SelectedItem = SelectedItem
- Else
- Add(value, "Unknown code " & value)
- Me.SelectedItem = value
- End If
- End If
- End Set
- End Property
- Public Sub RemoveElement(ByVal Name As String)
- Code = Name
- Items.RemoveAt(SelectedIndex)
- Dim Description = _CodeDescriptions(Name)
- _CodeDescriptions.Remove(Name)
- _DescriptionCodes.Remove(Description)
- End Sub
- End Class
Expand|Select|Wrap|Line Numbers
- ccDefaultFrequencies.Clear()
- For Each objFrequency In objVisitFrequencies.Values
- With objFrequency
- ccDefaultFrequencies.Add(.FrequencyId, .Description)
- End With
- Next
Expand|Select|Wrap|Line Numbers
- ccDefaultFrequencies.Code = "WEEK"
Expand|Select|Wrap|Line Numbers
- DefaultFrequency = ccDefaultFrequencies.Code