Imaginecorp
IS-IT--Management
There is a little bit of cheating here, but without a lot of convoluted code, this is how you do it. The code is amazingly simple.
As the grid displays records in a table, there is no way of knowing what a record contains unless you go to it. That is what this example does by moving the mouse through the rows and columns: Please feel free to fine tune;
As the grid displays records in a table, there is no way of knowing what a record contains unless you go to it. That is what this example does by moving the mouse through the rows and columns: Please feel free to fine tune;
Code:
PUBLIC oform1
oform1=NEWOBJECT("form1")
oform1.Show
RETURN
**************************************************
*-- Form: form1 (c:\imaginecorp\form11.scx)
*-- ParentClass: form
*-- BaseClass: form
*-- Time Stamp: 04/29/07 01:27:09 PM
*
DEFINE CLASS form1 AS form
Top = 0
Left = 0
Height = 269
Width = 495
DoCreate = .T.
ShowTips = .T.
Caption = "Display information in Tool Tip..."
Name = "Form1"
ADD OBJECT grid1 AS grid WITH ;
ColumnCount = 3, ;
DeleteMark = .F., ;
Height = 250, ;
Left = 8, ;
Panel = 1, ;
RecordSource = "customers", ;
ScrollBars = 2, ;
Top = 7, ;
Width = 480, ;
Name = "Grid1", ;
Column1.ControlSource = "Customers.customerid", ;
Column1.Width = 86, ;
Column1.Name = "Column1", ;
Column2.ControlSource = "Customers.companyname", ;
Column2.Width = 193, ;
Column2.Name = "Column2", ;
Column3.ControlSource = "Customers.contactname", ;
Column3.Width = 166, ;
Column3.Name = "Column3"
ADD OBJECT form1.grid1.column1.header1 AS header WITH ;
Caption = "Customer ID", ;
Name = "Header1"
ADD OBJECT form1.grid1.column1.text1 AS textbox WITH ;
BorderStyle = 0, ;
Margin = 0, ;
ForeColor = RGB(0,0,0), ;
BackColor = RGB(255,255,255), ;
Name = "Text1"
ADD OBJECT form1.grid1.column2.header1 AS header WITH ;
Caption = "Company Name", ;
Name = "Header1"
ADD OBJECT form1.grid1.column2.text1 AS textbox WITH ;
BorderStyle = 0, ;
Margin = 0, ;
ForeColor = RGB(0,0,0), ;
BackColor = RGB(255,255,255), ;
Name = "Text1"
ADD OBJECT form1.grid1.column3.header1 AS header WITH ;
Caption = "Contact", ;
Name = "Header1"
ADD OBJECT form1.grid1.column3.text1 AS textbox WITH ;
BorderStyle = 0, ;
Margin = 0, ;
ForeColor = RGB(0,0,0), ;
BackColor = RGB(255,255,255), ;
Name = "Text1"
PROCEDURE gridshowinfo
Lparameters pY,pX,pColumn
Store 0 To nWhere_Out ,nRelRow_Out, nRelCol_Out, nView_Out
With This.grid1
.GridHitTest(pX,pY,@nWhere_Out)
If nWhere_Out = 3
nr = Ceiling(Round((pY - (Objtoclient(This.grid1,1)+;
.HeaderHeight))/.RowHeight,0))
.ActivateCell(nr,pColumn)
cAddress = Alltrim(Nvl(customers.address,""))+Chr(13)+;
ALLTRIM(Nvl(customers.city,""))+Chr(13)+;
NVL(customers.postalcode,"")+". "+Alltrim(Nvl(customers.country,""))
cTitle = Alltrim(Nvl(customers.contacttitle,""))+Chr(13)+;
"Phone: "+Nvl(customers.phone,"")+Chr(13)+;
"Fax: "+Nvl(customers.Fax,"")
.ToolTipText = Icase(pColumn = 2,cAddress,;
pColumn = 3,cTitle,"")
Else
.ToolTipText = ""
Endif
Endwith
ENDPROC
PROCEDURE Load
If Select("customers") > 0
Select customers
Else
Select 0
Use Home()+"\samples\northwind\customers.dbf" Shared
Endif
ENDPROC
PROCEDURE grid1.Column1.MouseMove
LPARAMETERS nButton, nShift, nXCoord, nYCoord
thisform.gridshowinfo(nYCoord,nXCoord,1)
ENDPROC
PROCEDURE grid1.Column2.MouseMove
LPARAMETERS nButton, nShift, nXCoord, nYCoord
thisform.gridshowinfo(nYCoord,nXCoord,2)
ENDPROC
PROCEDURE grid1.Column3.MouseMove
LPARAMETERS nButton, nShift, nXCoord, nYCoord
thisform.gridshowinfo(nYCoord,nXCoord,3)
ENDPROC
ENDDEFINE
*
*-- EndDefine: form1
**************************************************