Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Generic grid class
Message
De
20/07/2000 13:49:51
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
20/07/2000 11:53:48
Emerson Reed
Folhamatic Tecnologia Em Sistemas
Americana - São Paulo, Brésil
Information générale
Forum:
Visual FoxPro
Catégorie:
Classes - VCX
Divers
Thread ID:
00394948
Message ID:
00395018
Vues:
12
>I'm creating a generic grid class.
>At run time I set the recordsource of this grid to the table I want to show.
>For each new column added to the grid, I want to insert in the click method of the header, a little bit of code ( for example: Thisformset.Atualiza() ).
>How can I do this?


Header, column are not visual classes. For that reason it's easier to do it in a prg. ie:
DEFINE class MyGrid as grid
  DeleteMark = .F.
  Height = 300
  Left = 28
  RecordMark = .F.
  Top = 0
  Width = 600
  Editmode=.T.
  SplitBar=.F.
  Name = "grdCustom"

  PROCEDURE addcolumn
  LPARAMETERS nIndex, cAlias, cField, tnWidth
  NODEFAULT
  this.addobject("clm"+cField,"MyColumn", nIndex, cAlias+"."+cField, tnWidth)
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),.Columns(ix).Width)
    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 nIndex, cControlSource, tnWidth
  WITH this
    .Width = tnWidth
    .controlsource = cControlSource
    .ColumnOrder = nIndex
    .AddObject("MyText","MyGridTxtBox")
    .removeobject("Header1")
    .Addobject("Header1","MyHeader",.ControlSource)
    .CurrentControl = "MyText"
    .Sparse = .F.
    .DynamicBackColor = ;
    "iif(type('"+.ControlSource+"')='D', rgb(192,192,192),"+;
    "iif(type('"+.ControlSource+"')='T', rgb(0,255,0),"+;
    "iif(type('"+.ControlSource+"')='N', rgb(0,128,0),rgb(255,255,255) )))"
  ENDWITH
ENDPROC
  PROCEDURE click
  WAIT window nowait 'This is column click'
ENDPROC
ENDDEFINE


DEFINE class MyGridTxtBox as TextBox
  Name = "Text1"
  SelectOnEntry = .T.
  BorderStyle = 0
  PROCEDURE when
  RETURN  ( this.parent.parent.Editmode )
ENDPROC

  PROCEDURE click
  WITH this
    .Selstart =0
    .Sellength = 9999
  ENDWITH
ENDPROC
ENDDEFINE

DEFINE class MyHeader as Header
  Name = "Header1"
  PROCEDURE init
  LPARAMETERS tcSource
  Activate screen
  tcCaption = dbgetprop(tcSource, 'Field','Caption')
  tcCaption = iif(empty(tcCaption),substr(tcSource,at('.',tcSource)+1),tcCaption)
  WITH this
    .Alignment = 2
    .Backcolor = rgb(255,255,0)
    .Forecolor = rgb(0,0,255)
    .Caption = tcCaption
  ENDWITH
ENDPROC
  PROCEDURE click
  this.caption = iif(isupper(this.caption),lower(this.caption),upper(this.caption))
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