第4 個問題已解決, 在 EditModeOff 事件里, 用 MultiColumnEditor 可以得出MultiColumnCombobox 里各 column 的值及帶出. 如下:
Private Sub FpSpread1_EditModeOff(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FpSpread1.EditModeOff
Dim colIndex As Integer
Dim mce As MultiColumnEditor = TryCast(FpSpread1.EditingControl, MultiColumnEditor)
If mce Is Nothing Then Exit Sub ' 不是 MultiColumnCombobox 時離開
If FpSpread1.ActiveSheet.Cells(FpSpread1.ActiveSheet.ActiveRowIndex, FpSpread1.ActiveSheet.ActiveColumnIndex).Value = Nothing Then Exit Sub '為空值時離開
If FpSpread1.ActiveSheet.Cells(FpSpread1.ActiveSheet.ActiveRowIndex, FpSpread1.ActiveSheet.ActiveColumnIndex).Value.ToString = "" Then Exit Sub '為空值時離開
colIndex = FpSpread1.ActiveSheet.ActiveColumnIndex
Try
Dim c As FpSpread = TryCast(mce.SubEditor, FpSpread)
Select Case colIndex
Case 0 'Column 0 MultiColumnComboBoxCellType 這個例子里有 2 個 MultiColumnCombobox
FpSpread1.ActiveSheet.Cells(FpSpread1.ActiveSheet.ActiveRowIndex, 1).Value = c.ActiveSheet.Cells(c.ActiveSheet.ActiveRowIndex, 1).Value
Case 1 'Column 1 MultiColumnComboBoxCellType
FpSpread1.ActiveSheet.Cells(FpSpread1.ActiveSheet.ActiveRowIndex, 2).Value = c.ActiveSheet.Cells(c.ActiveSheet.ActiveRowIndex, 1).Value ' 取 MultiColumnCombobox 里的第2欄
FpSpread1.ActiveSheet.Cells(FpSpread1.ActiveSheet.ActiveRowIndex, 3).Value = c.ActiveSheet.Cells(c.ActiveSheet.ActiveRowIndex, 2).Value
FpSpread1.ActiveSheet.Cells(FpSpread1.ActiveSheet.ActiveRowIndex, 4).Value = c.ActiveSheet.Cells(c.ActiveSheet.ActiveRowIndex, 3).Value
End Select
Catch ex As Exception
End Try
End Sub |