求教,如何在Spread Win Form7 中处理旧版本的ButtonClicked事件?
新的ButtonClicked事件的响应范围以及事件消息类型都跟旧版本不同。
特别是ButtonDown这个事件属性,该如何获取?
以下是自定义事件的相关内容。
- Public Shadows Event ButtonClicked(ByVal sender As Object, ByVal e As _DSpreadEvents_ButtonClickedEvent)
- Private Sub MyBase_ButtonClicked(ByVal sender As Object, ByVal e As FarPoint.Win.Spread.EditorNotifyEventArgs) Handles MyBase.ButtonClicked
- Dim buttonDown As Integer = 0
- '追加旧Spread的ButtonClicked事件参数ButtonDown
- '根据旧版本资料,Cell类型是复选框的时候,ButtonDown属性仅在复选框为选择或者灰色状态时为1
- ' Cell类型是按钮时,ButtonDown属性,仅在按钮被按下状态时,返回True。
- If checkButtonDown(e.Row, e.Column) = True Then
- buttonDown = 1
- End If
- Dim args = New _DSpreadEvents_ButtonClickedEvent(e.Column, e.Row, buttonDown)
- RaiseEvent ButtonClicked(sender, args)
- End Sub
- ' 增加判断函数,创建ButtonDown属性
- Private Function checkButtonDown(ByVal row As Integer, ByVal col As Integer) As Boolean
- If MyBase.ActiveSheet IsNot Nothing Then
- If TypeOf MyBase.ActiveSheet.Cells(row, col).CellType Is CellType.CheckBoxCellType Then
- '复选框状态为选择,灰色的时候, ButtonDown = True
- If MyBase.ActiveSheet.Cells(row, col).Value <> 0 Then
- Return True
- End If
- ElseIf TypeOf MyBase.ActiveSheet.Cells(row, col).CellType Is CellType.ButtonCellType Then
- ' 问题: 如何获得按钮为按下状态?
- Return True
- End If
- End If
- Return False
- End Function
- ''' <summary>
- ''' 自定义消息类型ButtonClicked
- ''' </summary>
- ''' <remarks></remarks>
- Public Class _DSpreadEvents_ButtonClickedEvent
- '列
- Private _Col As Integer
- '行
- Private _Row As Integer
- '按钮
- Private _ButtonDown As Integer
- ''' <summary>
- ''' 构造函数
- ''' </summary>
- ''' <param name="col">列</param>
- ''' <param name="row">行</param>
- ''' <remarks></remarks>
- Public Sub New(ByVal col As Integer, ByVal row As Integer, ByVal button As Integer)
- Me._Col = col + 1
- Me._Row = row + 1
- Me._ButtonDown = button
- End Sub
- ''' <summary>
- ''' 列
- ''' </summary>
- ''' <value></value>
- ''' <returns></returns>
- ''' <remarks></remarks>
- Public Property Col() As Integer
- Get
- Return _Col + 1
- End Get
- Set(value As Integer)
- _Col = value
- End Set
- End Property
- ''' <summary>
- ''' 行
- ''' </summary>
- ''' <value></value>
- ''' <returns></returns>
- ''' <remarks></remarks>
- Public Property Row() As Integer
- Get
- Return _Row + 1
- End Get
- Set(value As Integer)
- _Row = value
- End Set
- End Property
- ''' <summary>
- ''' 按钮状态
- ''' </summary>
- ''' <value></value>
- ''' <returns></returns>
- ''' <remarks></remarks>
- Public Property ButtonDown() As Integer
- Get
- Return _ButtonDown
- End Get
- Set(value As Integer)
- _ButtonDown = value
- End Set
- End Property
- End Class
复制代码
请不吝赐教。 |
|