A
AMDRIT
Hello Everyone,
I would like to format the Display Members of a combobox's datasource. Is
there a way to apply a format without subclassing the original datasource?
For example, given a list of decimal values, format them as currency values
with a leading currency symbol and 2 decimal places.
TIA
Class Test
Dim SelectionList As ArrayList
Dim cbo As ComboBox
Public Sub New()
SelectionList = New ArrayList
SelectionList.AddRange(New DataElements() {New DataElements(1D, 1), New
DataElements(1.15D, 2), New DataElements(1.3D, 3)})
cbo = New ComboBox
cbo.DataSource = SelectionList
cbo.DisplayMember = "Value"
cbo.ValueMember = "Index"
End Sub
Public Class DataElements
Private m_Value As Decimal
Private m_Index As Integer
Public Sub New(ByVal Value As Decimal, ByVal Index As Integer)
m_Value = Value
m_Index = Index
End Sub
Public ReadOnly Property Value() As Decimal
Get
Return m_Value
End Get
End Property
Public ReadOnly Property Index() As Integer
Get
Return m_Index
End Get
End Property
End Class
End Class
I would like to format the Display Members of a combobox's datasource. Is
there a way to apply a format without subclassing the original datasource?
For example, given a list of decimal values, format them as currency values
with a leading currency symbol and 2 decimal places.
TIA
Class Test
Dim SelectionList As ArrayList
Dim cbo As ComboBox
Public Sub New()
SelectionList = New ArrayList
SelectionList.AddRange(New DataElements() {New DataElements(1D, 1), New
DataElements(1.15D, 2), New DataElements(1.3D, 3)})
cbo = New ComboBox
cbo.DataSource = SelectionList
cbo.DisplayMember = "Value"
cbo.ValueMember = "Index"
End Sub
Public Class DataElements
Private m_Value As Decimal
Private m_Index As Integer
Public Sub New(ByVal Value As Decimal, ByVal Index As Integer)
m_Value = Value
m_Index = Index
End Sub
Public ReadOnly Property Value() As Decimal
Get
Return m_Value
End Get
End Property
Public ReadOnly Property Index() As Integer
Get
Return m_Index
End Get
End Property
End Class
End Class