I have two
columns:
1. “Status”
an unbound column which contains a ComboBox with a selection of status type
descriptions.
2. “StatusID”
a bound, invisible column that contains the StatusID (an integer value)
I am trying
to change the StatusID value based on the Status value the user changes via a
combo box.
What I have
so far is:
I created
the following class:
Public Class ListItem
Public ItemText As String ' what is
displayed
Public ItemData As Integer ' associated data
Public Overrides Function ToString() As
String
Return ItemText
End Function
End Class
I created
by combo box editor:
Private TestComboBox As New WinComboBox()
Private ListBoxData
As New ListItem
I added data to the combo box:
ListBoxData = New
ListItem
ListBoxData.ItemText = "Item 1"
ListBoxData.ItemData = 1
TestComboBox.Items.Add(ListBoxData)
ListBoxData = New
ListItem
ListBoxData.ItemText = "Item 2"
ListBoxData.ItemData = 2
TestComboBox.Items.Add(ListBoxData)
I created the
columns, attached the combo box to the column, and added the handler
grdData.Columns.Add(New
Column("Status", GetType(String)))
grdData.Columns("Status").CellEditorManager
= New ComboBoxEditor(TestComboBox)
grdData.Columns.Add(New
Column("StatusID", GetType(Integer)))
AddHandler
grdData.DataRowTemplate.Cells("Status").LeavingEdit,
AddressOf Status_LeavingEdit
The “Status” cell
updates as it should, but I can not figure how to update the “StatusID” cell. The following does not work:
Private Sub Status_LeavingEdit(ByVal
sender As Object,
ByVal e As
LeavingEditEventArgs)
Dim Cell As Cell = CType(sender,
Cell)
ListBoxData = CType(Cell.Value,
ListItem)
'MsgBox(ListBoxData.ItemData.ToString)
End Sub
Can anyone help?