Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Header click event in a grid with columncount -1
Message
De
22/03/2001 03:02:57
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
22/03/2001 02:24:31
Rasheed Al Rasheed
Riyadh Armed Forces Hospital
Riyadh, Arabie Saoudite
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Divers
Thread ID:
00487524
Message ID:
00487530
Vues:
14
>Hi all ;
> The header click event is realy cool for placing codes to sort or color data in a grid, however, I frquently use a grid with columncount -1 because I use queries to gather the data and column count changes according to requests.
>Is there is a way to place code in the header clickevent programically.
>
>Thanks

Rasheed,
Currently there is no native way I know. OTOH you could also build your grid from your subclassed column, header, textbox etc controls. Check Multiselectgrid class in files section ('Two grid classes') for a way. It simply replaces the header class with another header class kept in myheader.prg.
Or you can use this little 'build your own grid' approach :
on key label 'F2' clear events
use employee
oForm  = createobject('Form')
with oForm
	.Showtips = .T.
	.Addobject('myGrid','myGrid','employee')
	.myGrid.Visible = .t.
	.Show
endwith
read events

Define class myGrid as grid
  DeleteMark = .F.
  ReadOnly = .T.
  RecordMark = .F.
  ScrollBars = 2
  Splitbar = .F. 
  Name = "grdMyGrid"

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

  Procedure init
  Lparameters tcRecordsource
  With this
    .Columncount = -1
    .recordsource = tcRecordsource
    nOldColCount = .columncount
    For ix = 1 to fcount(tcRecordsource)
      .AddColumn(ix, tcRecordsource,field(ix,tcRecordsource))
    Endfor
    For ix = nOldColCount to 1 step -1
      .RemoveObject(.Columns(ix).name)
    Endfor
  Endwith
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 )
    .ActivateCell(lnActiveRow,3)
  Endwith
  This.setfocus()
  This.myText.Tooltiptext = iif(type(this.controlsource)='C',this.myText.Value,'')
Endproc
Enddefine


Define class myGridTxtBox as TextBox
  BackColor = rgb(0,0,255)
  ForeColor = rgb(255,255,255)
  SelectedBackColor = rgb(255,0,0)
  SelectedForeColor = rgb(255,255,0)
  Name = "Text1"
  Procedure init
  This.BorderStyle = 0
Endproc
  Procedure click
  This.setfocus()
Endproc
Enddefine

Define class myHeader as Header
  BackColor = 0
  ForeColor = rgb(255,255,0)
  Procedure init
  This.Caption = 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
Répondre
Fil
Voir

Click here to load this message in the networking platform