Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Grid and Container
Message
De
08/08/2006 09:14:32
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
08/08/2006 07:36:53
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 8
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Divers
Thread ID:
01143737
Message ID:
01143755
Vues:
11
>Hi all,
>
>I have a Form with one Grid and a Container over it, the grid have some records and a field with a long description, i need to display a tooltip of that long description when the user moves the mouse over the grid, for every record where the mouse is over. How can i do that...
>
>João Batista

In VFP9 you don't need to do anything, it's default behavior. In earliere versions:

In column mousemove, calculate the grid row and column that mouse is over (VFP8 have GridHitTest for that). ActivateCell( nRow, nCol ) and set text1.tooltiptext to eval(this.Controlsource). Here is an old code as sample:
Public oForm
oForm  = Createobject('myForm')
oForm.Show

Define Class myForm As Form
  DataSession = 2
  ShowTips = .T.
  Procedure Load
    Use employee
  Endproc
  Add Object myGrd As myGrid With RecordSource = 'Employee'
Enddefine

Define Class myGrid As Grid
  DeleteMark = .F.
  ReadOnly = .T.
  RecordMark = .F.
  ScrollBars = 3
  SplitBar = .F.
  Highlight = .F.
  HighlightRow = .F.
  Name = "grdMyGrid"

  Procedure AddColumn
    Lparameters nIndex, cAlias, cField
    Nodefault
    This.AddObject("clm"+cField,"myColumn", cAlias+"."+cField,nIndex)
  Endproc

  Procedure Init
    Lparameters tcRecordsource
    tcRecordSource = Iif(Empty(m.tcRecordSource),This.RecordSource,m.tcRecordSource)
    With This
      .ColumnCount = -1
      .RecordSource = tcRecordsource
      nOldColCount = .ColumnCount
      For ix = 1 To Fcount(tcRecordsource)
        .AddColumn(ix, tcRecordsource,Field(ix,tcRecordsource))
      Endfor
      .ColumnCount = nOldColCount
      .SetAll('Visible',.T.)
    Endwith
  Endproc

  Procedure When
    Set Cursor Off
  Endproc

  Procedure Valid
    Set Cursor On
  Endproc
Enddefine

Define Class myColumn As Column
  Resizable = .F.
  Movable = .F.
  Procedure Init
    Lparameters cControlSource, nIndex
    With This
      .ControlSource = cControlSource
      .ColumnOrder = nIndex
      .RemoveObject('Header1')
      .AddObject('myHeader','myHeader')
      .AddObject("myText","myGridTxtBox")
      .CurrentControl = "myText"
      .Sparse = .F.
    Endwith
  Endproc
  Procedure MouseMove
    Lparameters nButton, nShift, nXCoord, nYCoord
    With This.Parent
      lnActiveRow = Ceiling( ;
        ( nYCoord - (.Top + .HeaderHeight) ) / .RowHeight )
      lnActivecol = This.ColumnOrder - This.Parent.LeftColumn + 1
      .ActivateCell(lnActiveRow,lnActiveCol)
    Endwith
    This.myText.ToolTipText = ;
      iif(Type(This.ControlSource)='C',  Eval(This.ControlSource),;
      iif(Type(This.ControlSource)='M',  Mline(Eval(This.ControlSource),1),''))
  Endproc
Enddefine


Define Class myGridTxtBox As TextBox
  Procedure Init
    This.BorderStyle = 0
  Endproc
  Procedure Click
    This.SetFocus()
  Endproc
Enddefine

Define Class myHeader As Header
  Procedure Init
    This.Caption = Proper(Justext(This.Parent.ControlSource))
  Endproc
Enddefine
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform