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
/
Form1.vb
125 lines (113 loc) · 4.17 KB
/
Form1.vb
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
Imports Microsoft.VisualBasic
Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Text
Imports System.Windows.Forms
Imports DevExpress.XtraGrid
Imports DevExpress.XtraGrid.Views.Base
Imports DevExpress.XtraGrid.Views.Base.ViewInfo
Imports DevExpress.Utils
Imports DevExpress.XtraGrid.Views.Grid.ViewInfo
Imports DevExpress.XtraGrid.Views.Grid
Namespace WindowsApplication1
Partial Public Class Form1
Inherits Form
Private Function CreateTable(ByVal RowCount As Integer) As DataTable
Dim tbl As New DataTable("Parent")
tbl.Columns.Add("Name", GetType(String))
tbl.Columns.Add("ID", GetType(Integer))
tbl.Columns.Add("Number", GetType(Integer))
tbl.Columns.Add("Date", GetType(DateTime))
tbl.Columns.Add("DETAILID", GetType(Integer))
For i As Integer = 0 To RowCount - 1
tbl.Rows.Add(New Object() { String.Format("Name{0}", i), i, 3 - i, DateTime.Now.AddDays(i), i })
Next i
Return tbl
End Function
Private Function CreateDet1Table(ByVal RowCount As Integer) As DataTable
Dim tbl As New DataTable("Det1")
tbl.Columns.Add("Name", GetType(String))
tbl.Columns.Add("ID", GetType(Integer))
For j As Integer = 0 To RowCount - 1
For i As Integer = 0 To RowCount - 1
tbl.Rows.Add(New Object() { String.Format("Detail1Name{0}", i), i })
Next i
Next j
Return tbl
End Function
Private Function CreateDet2Table(ByVal RowCount As Integer) As DataTable
Dim tbl As New DataTable("Det2")
tbl.Columns.Add("Name", GetType(String))
tbl.Columns.Add("ID", GetType(Integer))
For j As Integer = 0 To RowCount - 1
For i As Integer = 0 To RowCount - 1
tbl.Rows.Add(New Object() { String.Format("Detail2Name{0}", i), i })
Next i
Next j
Return tbl
End Function
Private Function GetMasterDetail() As DataSet
Dim ds As New DataSet("TestDS")
ds.Tables.Add(CreateTable(20))
ds.Tables.Add(CreateDet1Table(20))
ds.Tables.Add(CreateDet2Table(20))
Dim parentColumn As DataColumn = ds.Tables("Parent").Columns("DETAILID")
Dim childColumn As DataColumn = ds.Tables("Det1").Columns("ID")
ds.Relations.Add(New DataRelation("relDet1", parentColumn, childColumn))
childColumn = ds.Tables("Det2").Columns("ID")
ds.Relations.Add(New DataRelation("relDet2", parentColumn, childColumn))
Return ds
End Function
Public Sub New()
InitializeComponent()
gridControl1.DataSource = GetMasterDetail()
gridControl1.DataMember = "Parent"
End Sub
Public Function GetToolTipByHitInfo(ByVal view As GridView, ByVal hi As GridHitInfo) As SuperToolTip
If hi Is Nothing Then
Return Nothing
End If
Dim toolTip As New SuperToolTip()
Dim caption As String
If view.GridControl.MainView.Equals(view) Then
caption = "Main View"
Else
caption = String.Format("DetailView: {0}", view.LevelName)
End If
toolTip.Items.AddTitle(caption)
toolTip.Items.AddSeparator()
If (Not hi.InRowCell) Then
Return Nothing
End If
toolTip.Items.Add(String.Format("Cell at {0}:", hi.HitPoint))
toolTip.Items.Add(String.Format("Column = {0}", hi.Column))
toolTip.Items.Add(String.Format("RowHandle = {0}", hi.RowHandle))
Return toolTip
End Function
Private Sub defaultToolTipController1_DefaultController_GetActiveObjectInfo(ByVal sender As Object, ByVal e As DevExpress.Utils.ToolTipControllerGetActiveObjectInfoEventArgs) Handles defaultToolTipController1.DefaultController.GetActiveObjectInfo
Dim gridControl As GridControl = TryCast(e.SelectedControl, GridControl)
If gridControl Is Nothing Then
Return
End If
Dim view As GridView = TryCast(gridControl.GetViewAt(e.ControlMousePosition), GridView)
If view Is Nothing Then
Return
End If
Dim hi As GridHitInfo = view.CalcHitInfo(e.ControlMousePosition)
Dim toolTip As SuperToolTip = GetToolTipByHitInfo(view, hi)
If toolTip Is Nothing Then
Return
End If
e.Info = New ToolTipControlInfo()
e.Info.Object = hi.Column
e.SelectedObject = hi.Column
e.Info.SuperTip = toolTip
e.Info.ToolTipType = ToolTipType.SuperTip
e.Info.ToolTipPosition = Control.MousePosition
e.Info.ImmediateToolTip = True
End Sub
End Class
End Namespace