Posted 9 January 2022, 7:15 am EST
The ComboBoxCellType updates a bound record after the user leaves the cell. Is there a way to force an update after the use selects a different item from the drop down list?
Here’s a quick and dirty example that I’d like to see the value in the second column change when the user selects an item in the first column.
Imports System.ComponentModel
Imports FarPoint.Win
Imports FarPoint.Win.Spread
Imports FarPoint.Win.Spread.CellType
Public Class Form1
Public months As BindingList(Of classMonth)
Private WithEvents ct As ComboBoxCellType
Private WithEvents wb As FpSpread
Private WithEvents ws As SheetView
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load
wb = New FpSpread
ws = New SheetView
wb.Sheets.Add(ws)
wb.Dock = DockStyle.Fill
Controls.Add(wb)
loadList()
ct = comboFromEnum(GetType(enumMonths))
ws.DataSource = months
ws.ColumnCount = 2
ws.Columns(0).DataField = "itemData"
ws.DataAutoHeadings = False
ws.DataAutoCellTypes = False
ws.Columns(0).CellType = ct
End Sub
Private Sub loadList()
months = New BindingList(Of classMonth)
months.Add(New classMonth(enumMonths.April))
months.Add(New classMonth(enumMonths.October))
months.Add(New classMonth(enumMonths.January))
End Sub
Public Function comboFromEnum(t As Type) As ComboBoxCellType
Dim result = New ComboBoxCellType
result.ItemData = Array.ConvertAll(Of Integer, String)(System.Enum.GetValues(t), Function(x) x.ToString())
result.Items = System.Enum.GetNames(t)
result.EditorValue = EditorValue.ItemData
result.DropDownOptions = DropDownOptions.Button
result.Editable = False
Return result
End Function
End Class
Public Class classMonth
Public Property number As enumMonths
Public Property itemData As String
Get
Return Int(number).ToString
End Get
Set(value As String)
[Enum].TryParse(value, number)
End Set
End Property
Public Sub New(number As enumMonths)
Me.number = number
End Sub
End Class
Public Enum enumMonths
January
February
March
April
May
June
July
August
September
October
November
December
End Enum