Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Subclassing grid
Message
From
03/04/1999 12:03:18
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Miscellaneous
Thread ID:
00204932
Message ID:
00204950
Views:
15
>Hi all,
>I'm trying to sibclassing a grid columns.
>I'll like to use a custom Header and a custom textbox
>My code look like this:
>
>
Define Class tateHeader As Header
>	FontSize = 8
>	FontName = "Arial"
>	Alignment = 2
>	Procedure Click
>		This.parent.parent.SortGrid(This.parent.ColumnOrder)
>		This.parent.parent.SetAll( "FontBold", .F., "tateHeader" )
>		This.FontBold = .T.
>	EndProc
>EndDefine
>
>Define Class tateColumn As Column
>	Procedure Init
>		Set ClassLib To ..\shared\libs\autoABM Additive
>		With This
>			.RemoveObject( "header1" )
>			.AddObject( "Header1", "tateHeader" )
>			.RemoveObject( "Text1" )
>			.AddObject( "txtDato", "browseTextBox" )
>			.CurrentControl = "txtDato"
>			.Sparse = .F.
>			.Bound = .F.
>		EndWith
>	EndProc
>	
>	Procedure ControlSource_Assign
>		LParameter uNewVal
>		This.txtDato.ControlSource = uNewVal
>		This.ControlSource = uNewVal
>	EndProc
>EndDefine
>
>At the form init:
>
>
With Thisform
>	.LockScreen = .T.
>	cSQL = 'Select ' + .abmCampos + ' From ' + .abmTablas + ' Where ' + .abmCondicion + ' Order By '+ AllTrim(Str(.abmOrden))+' '+ .abmTipoOrden + ' Into Cursor cur'+.Name
>	&cSQL
>	With .grdBrowse
>		.RecordSourceType = 1
>		.RecordSource = 'cur'+.Name
>	EndWith
>	.CreateColumns()
>	.LockScreen = .F.
>	.grdBrowse.SetFocus()
>EndWith
>At form CreateColumns method:
>
Dimension aCampos[This.abmColumnas,2]
>With This
>	For i = 1 To .abmColumnas
>		aCampos[i,1] = .grdBrowse.Columns[i].ControlSource
>		aCampos[i,2] = .grdBrowse.Columns[i].Width
>	EndFor
>
>	.grdBrowse.ColumnCount = 0
>	For i = 1 To .abmColumnas-1
>		lcObject = "Column"+Trans(i)
>		nPrim  = Iif( i=1, 1, Atc( ";", .abmColumnTitles, i-1 )+1 )
>		nCuan  = Atc( ";", .abmColumnTitles, i ) - nPrim
>		cTitu = SubStr( .abmColumnTitles, nPrim, nCuan )
>		With .grdBrowse
>			.AddObject(lcObject,"tateColumn")
>			.&lcObject..ControlSource = aCampos[i,1]
>			.&lcObject..Width = aCampos[i,2]
>			.&lcObject..Header1.Caption = cTitu
>			.&lcObject..Refresh()
>		EndWith
>	EndFor
>	cTitu = SubStr( This.abmColumnTitles, Rat( ";", This.abmColumnTitles ) + 1 )
>	lcObject = "Column"+Trans(i)
>	With .grdBrowse
>		.AddObject(lcObject,"tateColumn")
>		.&lcObject..ControlSource = aCampos[i,1]
>		.&lcObject..Width = aCampos[i,2]
>		.&lcObject..Header1.Caption = cTitu
>		.&lcObject..Refresh()
>	EndWith
>	.grdBrowse.Refresh()
>EndWith
>
>The problem is that NO DATA ARE SHOWED IN BOTH RECORDS AND HEADER
>
>What is missing?? Please Help me!
>Thanks in advance!!!!
Hi,
- Columncount = 0 and -1 are different.
- Since your column is only used for adding header class + txtDato, you could simply do that in grid.init w/o new column class. So controlsource assigning could be dropped and other properties could be preserved.
- If will add via column class instead of Addobject use Addcolumn.
- Since you're building a grid class, prevent external routines as much as possible (createcolumns() could be grid's method instead of an indiviual form).

For a sample you might check multiselectgrid class in files\classes section. It uses SQL, changes header and txtBox (not perfect but works).
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
Previous
Reply
Map
View

Click here to load this message in the networking platform