前几天一朋友问我C1FlexGrid中如何实现Excel一样计算的功能,想了一下,觉得应该可以实现,于是做了个小例子。 运行结果基本上还算可以,只是中间有些地方还需要完善,也有一些没有解决掉的问题。如果有什么更好的办法,请大家指教。 程序打包如下: FlexGridSample.rar 需要环境: Microsoft Visual Studio 2005 Version 8.0.50727.762 (SP.050727-7600) .NET版本:Microsoft .NET Framework Version 2.0.50727 C1FlexGrid版本:Version 2.6.20071.324
''' <summary> ''' 计算规则信息 ''' </summary> ''' <remarks></remarks> PublicClass CalculateInfoClass CalculateInfo Private _calType As CalculateType Private _x AsInteger Private _y AsInteger Private _xRef AsInteger Private _yRef AsInteger Private _cal As Calculate Private _value AsInteger Property calType()Property calType() As CalculateType Get Return _calType EndGet Set(ByVal value As CalculateType) _calType = value EndSet End Property Property x()Property x() AsInteger Get Return _x EndGet Set(ByVal value AsInteger) _x = value EndSet End Property Property y()Property y() AsInteger Get Return _y EndGet Set(ByVal value AsInteger) _y = value EndSet End Property Property xRef()Property xRef() AsInteger Get Return _xRef EndGet Set(ByVal value AsInteger) _xRef = value EndSet End Property Property yRef()Property yRef() AsInteger Get Return _yRef EndGet Set(ByVal value AsInteger) _yRef = value EndSet End Property Property cal()Property cal() As Calculate Get Return _cal EndGet Set(ByVal value As Calculate) _cal = value EndSet End Property Property value()Property value() AsInteger Get Return _value EndGet Set(ByVal value AsInteger) _value = value EndSet End Property End Class
PublicClass CalculateUtilClass CalculateUtil PublicSharedFunction Compute()Function Compute(ByVal cellValue AsInteger, ByVal value AsInteger, ByVal cal As Calculate) AsInteger SelectCase cal Case Calculate.ADDITION Return cellValue + value Case Calculate.SUBTRACTION Return cellValue - value Case Calculate.MULTIPLICATION Return cellValue * value Case Calculate.DIVISION If value =0Then Return0 Else Return cellValue value EndIf EndSelect End Function End Class
前几天一朋友问我C1FlexGrid中如何实现Excel一样计算的功能,想了一下,觉得应该可以实现,于是做了个小例子。运行结果基本上还算可以,只是中间有些地方还需要完善,也有一些没有解决掉的问题。如果有什么更好的办法,请大家指教。程序打包如下: FlexGridSample.rar需要环境: Microsoft Visual Studio 2005 Version 8.0.50727.762