This repository has been archived by the owner on Sep 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MyGridView.cs
48 lines (43 loc) · 1.68 KB
/
MyGridView.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
using System;
using DevExpress.XtraGrid.Scrolling;
using System.Windows.Forms;
using System.Drawing;
using DevExpress.Utils;
namespace MyXtraGrid {
public class MyGridView : DevExpress.XtraGrid.Views.Grid.GridView {
public MyGridView() : this(null) {}
public MyGridView(DevExpress.XtraGrid.GridControl grid) : base(grid) {
}
protected override string ViewName { get { return "MyGridView"; } }
protected override ScrollInfo CreateScrollInfo()
{
ScrollInfo newMyScrollInfo = base.CreateScrollInfo();
newMyScrollInfo.VScroll.Scroll += VScroll_Scroll;
return newMyScrollInfo;
}
void VScroll_Scroll(object sender, ScrollEventArgs e)
{
if (e.Type == ScrollEventType.ThumbTrack)
{
Point p = GridControl.PointToScreen(((VCrkScrollBar)sender).Location);
p.Y = Control.MousePosition.Y;
MyShowHint(p, DevExpress.Utils.ToolTipLocation.TopLeft);
}
}
string GetToolTipText()
{
return string.Format("{0} - {1}", TopRowIndex, TopRowIndex + ViewInfo.RowsLoadInfo.ResultRowCount - 1);
}
protected virtual void MyShowHint(Point position, ToolTipLocation location)
{
if (GridControl == null) return;
ToolTipControllerShowEventArgs tool = GridControl.ToolTipController.CreateShowArgs();
tool.ToolTip = GetToolTipText();
tool.SelectedObject = this;
tool.SelectedControl = GridControl;
tool.AutoHide = false;
tool.ToolTipLocation = location;
GridControl.ToolTipController.ShowHint(tool, position);
}
}
}