大概就是这样一个思路
- ToolTip toolTip = new ToolTip();
- private void MainWindow_Loaded(object sender, RoutedEventArgs e)
- {
- gcSpreadSheet1.ToolTip = toolTip;
- gcSpreadSheet1.MouseMove += GcSpreadSheet1_MouseMove;
- gcSpreadSheet1.ActiveSheet.Cells[0, 0].Tag = "Hi !";
- gcSpreadSheet1.ActiveSheet.Cells[3, 3].Tag = "Hi 2";
- }
- private void GcSpreadSheet1_MouseMove(object sender, MouseEventArgs e)
- {
- var point = e.GetPosition(this.gcSpreadSheet1);
- var info = this.gcSpreadSheet1.HitTest(point.X, point.Y);
- toolTip.IsOpen = false;
- if (info.HitTestType == HitTestType.Viewport && info.ViewportInfo != null)
- {
- var cell = gcSpreadSheet1.ActiveSheet.Cells[info.ViewportInfo.Row, info.ViewportInfo.Column];
- if (cell.Tag != null)
- {
- toolTip.Content = cell.Tag.ToString();
- toolTip.IsOpen = true;
- }
- }
- }
复制代码
|