回复 3楼yangsq的帖子
Imports FarPoint.Win
Public Class Form2
Dim bttncell As New FarPoint.Win.Spread.CellType.ButtonCellType()
Dim flg As Boolean = False
Private Sub Form2_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
bttncell.Text = "Click"
bttncell.TextColor = Color.Black
bttncell.WordWrap = True
Me.FpSpread1.ActiveSheet.ColumnHeader.Columns(0).CellType = bttncell
End Sub
Private Sub FpSpread1_MouseDown(sender As System.Object, e As System.Windows.Forms.MouseEventArgs) Handles FpSpread1.MouseDown
If (e.Button = System.Windows.Forms.MouseButtons.Left) Then
Dim ht As FarPoint.Win.Spread.HitTestInformation = Me.FpSpread1.HitTest(e.X, e.Y)
If (ht.Type = FarPoint.Win.Spread.HitTestType.ColumnHeader) And flg = False Then
bttncell.TextColor = Color.Gray
Me.FpSpread1.ActiveSheet.ColumnHeader.Columns(0).CellType = bttncell
flg = True
End If
End If
End Sub
Private Sub FpSpread1_MouseUp(sender As System.Object, e As System.Windows.Forms.MouseEventArgs) Handles FpSpread1.MouseUp
If (e.Button = System.Windows.Forms.MouseButtons.Left) Then
Dim ht As FarPoint.Win.Spread.HitTestInformation = Me.FpSpread1.HitTest(e.X, e.Y)
If flg = True Then
bttncell.TextColor = Color.Black
Me.FpSpread1.ActiveSheet.ColumnHeader.Columns(0).CellType = bttncell
flg = False
End If
End If
End Sub
End Class
我这样做大概能实现想要的效果,但是还是有我上面说的问题,另外就是在按钮上压下之后,去其他地方松开,按钮不会恢复,原因好像是按钮的效果没反映上去,切换下画面什么的再回来颜色就会恢复,这种问题有解决方案吗? |