找回密码
 立即注册

QQ登录

只需一步,快速开始

恶马Maximus

银牌会员

4

主题

9

帖子

3138

积分

银牌会员

积分
3138

活字格认证

恶马Maximus
银牌会员   /  发表于:2013-5-8 11:09  /   查看:6025  /  回复:6
如题。
我知道FpSpread有MouseEnter事件,但是是针对FpSpread控件。有没有SheetView.Cell的MouseEnter事件呢。
本来可以用EnterCell来实现,但是这样会需要点选Cell。FpSpead可不可以实现鼠标移入某个SheetView的Cell就可以出现提示框的功能呢。

6 个回复

倒序浏览
Ally
葡萄城公司职员   /  发表于:2013-5-8 13:46:00
沙发
您可以使用CellNote来实现。
fpSpread1.ActiveSheet.Cells[5, 5].Note = "this is cells[5, 5]";
fpSpread1.ActiveSheet.Cells[5, 5].NoteStyle = NoteStyle.PopupNote;
当鼠标Hover到NoteIndicator时,将显示提示信息。
回复 使用道具 举报
恶马Maximus
银牌会员   /  发表于:2013-5-8 15:53:00
板凳
回复 2楼Ally的帖子

你好 谢谢你的回复
已经能够解决我的问题了。有一个小问题就是,NoteIndicator的size太小。有一个NoteIndicatorSize的字段可以解决。但是这个字段在哪都找不到。
回复 使用道具 举报
Ally
葡萄城公司职员   /  发表于:2013-5-8 16:07:00
地板
这个字段在cell上:
fpSpread1.ActiveSheet.Cells[5, 5].NoteIndicatorSize = new Size(10,10);
回复 使用道具 举报
Ally
葡萄城公司职员   /  发表于:2013-5-8 16:12:00
5#
您也可以尝试以下方法,希望对您有用。
bool flag = true;
public Form1()
        {
            fpSpread1.GotFocus += fpSpread1_GotFocus;
            fpSpread1.LostFocus += fpSpread1_LostFocus;
         }
void fpSpread1_MouseMove(object sender, MouseEventArgs e)
        {
                HitTestInformation infor = this.fpSpread1.HitTest(e.X, e.Y);
                if (infor.Type == HitTestType.Viewport)
                {
                    if (infor.ViewportInfo.Column == 3 && infor.ViewportInfo.Row == 3 && flag)
                    {
                        MessageBox.Show("Cell " + infor.ViewportInfo.Column.ToString() + ":" + infor.ViewportInfo.Row.ToString());
                    }
                }
        }

        void fpSpread1_LostFocus(object sender, EventArgs e)
        {
            fpSpread1.MouseMove -= fpSpread1_MouseMove;           
        }

        void fpSpread1_GotFocus(object sender, EventArgs e)
        {
            flag = true;
            fpSpread1.MouseMove += fpSpread1_MouseMove;      
        }
运行以上代码后,当鼠标Hover到Cells[3, 3]上时将弹出MessageBox。
回复 使用道具 举报
恶马Maximus
银牌会员   /  发表于:2013-5-8 16:23:00
6#
回复 5楼Ally的帖子

U are great!
我查询了下NoteIndicatorSize是Cell的字段,但是我在VisulStudio编写代码时就是报没有这个属性的错误。我用的Farpoint V12.0,这个字段存在于这个版本中么。
另 你的MouseMove的代码看上去很赞,能麻烦写一个VB.net版本么
回复 使用道具 举报
Ally
葡萄城公司职员   /  发表于:2013-5-9 09:52:00
7#
以下是VB代码:
Public Class Form1
    Dim flag As Boolean = True
    Public Sub New()
        InitializeComponent()
    End Sub

    Private Sub FpSpread1_GotFocus(sender As Object, e As EventArgs) Handles FpSpread1.GotFocus
        flag = True
        AddHandler FpSpread1.MouseMove, AddressOf FpSpread1_MouseMove
    End Sub
    Private Sub FpSpread1_LostFocus(sender As Object, e As EventArgs) Handles FpSpread1.LostFocus
        RemoveHandler FpSpread1.MouseMove, AddressOf FpSpread1_MouseMove
    End Sub
    Private Sub FpSpread1_MouseMove(sender As Object, e As MouseEventArgs)
        Dim infor As HitTestInformation = Me.FpSpread1.HitTest(e.X, e.Y)
        If infor.Type = HitTestType.Viewport Then
            If infor.ViewportInfo.Column = 3 AndAlso infor.ViewportInfo.Row = 3 AndAlso flag Then
                MessageBox.Show("Cell " & infor.ViewportInfo.Column.ToString() & ":" & infor.ViewportInfo.Row.ToString())
            End If
        End If
    End Sub
End Class
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部