On 2014-05-29 14:20, Kurt @ VR-FX wrote:
To add a little to what Mike just wrote - and follow-up with your Q
re:Builder. To be honest, I generally never use the Builder. Most
times, my Grid is based upon an actual Table. As such, what I like to
is create Grid via the Visual Design method. On a Form i will add a
Table to the Data Env. - then, from within the DE - I select a bunch
of the fields listed in the Table - and drag that onto the Form. That
will create the Basic Grid for me - at which point I then go nuts to
modify it and make it fully functional...
I set a method in my framework's grid class bazillion years ago that set
the column controlsources for me. Many thanks to Paul Mrozowski for the
SaveSource/RestoreSource code. The only caveat on me is that I name the
column.name to be the same as the field. Then it works great in my
class. Here's the code (you could get rid of that highlight crap):
**************************************************
*-- Class: grdbase (c:\dev\fabnet\classes\mjbbase.vcx)
*-- ParentClass: grid
*-- BaseClass: grid
*-- Time Stamp: 04/18/14 10:29:12 AM
*
DEFINE CLASS grdbase AS grid
AllowHeaderSizing = .F.
AllowRowSizing = .F.
DeleteMark = .F.
Height = 200
Width = 320
HighlightBackColor = RGB(255,255,40)
HighlightForeColor = RGB(0,0,0)
HighlightStyle = 2
*-- used in SaveSource/RestoreSource
ocolumninfo = .F.
*-- used in the SaveSource/RestoreSource methods
corigrecordsource = .F.
*-- set to .T. to have Init event set column controlsources
lsetcolumns = .F.
*-- in dblclick method, calls thisform.EditRecord if exists
leditondblclick = .T.
*-- XML Metadata for customizable properties
_memberdata = [<VFPData><memberdata name="leditondblclick"
display="lEditOnDblClick"/><memberdata name="lregisterasogrid"
display="lRegisterAsOGrid"/><memberdata name="ckey"
display="cKey"/><memberdata name="restoresource"
display="RestoreSource"/><memberdata name="savesource"
display="SaveSource"/><memberdata name="corigrecordsource"
display="cOrigRecordSource"/><memberdata name="lsetcolumns"
display="lSetColumns"/><memberdata name="ocolumninfo"
display="oColumnInfo"/></VFPData>]
*-- set to .T. to have grid register itself as thisform.oGrid in
grid.Init event.
lregisterasogrid = .T.
*-- active index for grid (mjb 04-13-14)
ckey = ""
Name = "grdbase"
PROCEDURE savesource
** Thanks Paul Mrozowski for this code
LOCAL loColumn as Column
This.oColumnInfo = CREATEOBJECT("Collection")
FOR EACH loColumn IN This.Columns
This.oColumnInfo.Add(loColumn.ControlSource)
loColumn.ControlSource = .NULL.
ENDFOR
This.cOrigRecordSource = This.RecordSource
This.RecordSource = .NULL.
ENDPROC
*-- restore previous column definitions
PROCEDURE restoresource
** Thanks Paul Mrozowski for this code
LOCAL liIndex as Integer, loColumn as Column
IF VARTYPE(This.oColumnInfo) <> "O"
RETURN
ENDIF
liIndex = 1
This.RecordSource = This.cOrigRecordSource
FOR EACH loColumn IN This.Columns
loColumn.ControlSource = This.oColumnInfo.Item[liIndex]
liIndex = liIndex + 1
ENDFOR
ENDPROC
PROCEDURE DblClick
IF this.lEditOnDblClick AND PEMSTATUS(thisform,thisform.cEditMethod,5)
AND NOT EMPTY(thisform.cEditMethod) THEN
LOCAL lcCmd as String
lcCmd = [thisform.] + thisform.cEditMethod + [()]
&lcCmd
ENDIF
ENDPROC
PROCEDURE Init
LOCAL loException as Exception
TRY
IF TYPE("oUtils.oSettings.cHighlightForeColor") = "C" AND
!EMPTY(oUtils.oSettings.cHighLightForeColor) THEN
this.HighlightForeColor =
EVALUATE(oUtils.oSettings.cHighlightForeColor)
ENDIF
CATCH TO loException
* ignore...just trap quietly...could report to MBSS
later if desired
IF _vfp.StartMode = 0 THEN && developer should be alerted when in dev
mode
MESSAGEBOX("Problem setting gridhighlightforecolor for " +
this.Name,16,"Color setting problem.")
ENDIF
ENDTRY
TRY
IF TYPE("oUtils.oSettings.cHighlightBackColor") = "C" AND
!EMPTY(oUtils.oSettings.cHighLightBackColor) THEN
this.HighlightBackColor =
EVALUATE(oUtils.oSettings.cHighlightBackColor)
ENDIF
CATCH TO loException
* ignore...just trap quietly...could report to MBSS
later if desired
IF _vfp.StartMode = 0 THEN && developer should be alerted when in dev
mode
MESSAGEBOX("Problem setting gridhighlightforecolor for " +
this.Name,16,"Color setting problem.")
ENDIF
ENDTRY
IF this.lRegisterAsOGrid THEN
thisform.oGrid = this
IF PEMSTATUS(thisform,"cAlias",5) AND NOT
EMPTY(thisform.cAlias) THEN
this.RecordSource = thisform.cAlias
ENDIF
ENDIF
IF this.lSetColumns THEN
LOCAL loColumn as Column
FOR EACH loColumn IN this.Columns
loColumn.ControlSource = this.RecordSource +
"." + loColumn.Name
ENDFOR
ENDIF && this.lSetColumns
ENDPROC
ENDDEFINE
*
*-- EndDefine: grdbase
**************************************************
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox
OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message:
http://leafe.com/archives/byMID/profox/[email protected]
** All postings, unless explicitly stated otherwise, are the opinions of the
author, and do not constitute legal or medical advice. This statement is added
to the messages for those lawyers who are too stupid to see the obvious.