>LPARAMETERS nButton, nShift, nXCoord, nYCoord >This.Parent.Parent.origcolnum = this.Parent.ColumnOrder>
>IF this.Parent.Parent.origcolnum = this.Parent.ColumnOrder > this.Parent.parent.SortGrid(this.Parent) >ENDIF>
>this.Parent.Parent.filtercolumn=this >this.parent.parent.DblClick()>
&& Form method - eg init =m.this.GridColumnCountChanged() =BindEvent(m.this.Grid1, 'ColumnCount', m.this, 'GridColumnCountChanged', 1)Code of 'GridColumnCountChanged'
Go through columns - if 'TheColumnBinder' is not in, add it with m.this.Grid1 local i for i = 1 to .ColumnCount with .Columns[m.i] do case case !Inlist(vartype(.TheColumnBinder), T_UNDEFINED) case !.AddObject('TheColumnBinder', 'TheColumnBinder') assert .f. endcase endwith endfor endwith(2) There are a number of possibilities
&& gridBinder *=============================================================================== #include "FoxPro.h" #define TRUE .T. #define FALSE .F. *=============================================================================== #define TRACE_HERE TRUE #if TRACE_HERE # define _SHOW do _DebugOut with program() #else # define _SHOW * #endif *=============================================================================== #define PARAMETERLIST_04 p01, p02, p03, p04 #define PARAMETERLIST_08 PARAMETERLIST_04, p05, p06, p07, p08 #define PARAMETERLIST_12 PARAMETERLIST_08, p09, p10, p11, p12 #define PARAMETERLIST_16 PARAMETERLIST_12, p13, p14, p15, p16 #define PARAMETERLIST_20 PARAMETERLIST_16, p17, p18, p19, p20 #define PARAMETERLIST_24 PARAMETERLIST_20, p21, p22, p23, p24 *=============================================================================== *_______________________________________________________________________________ function IsObject(obj, BaseClassName) if( pcount() == 1) return inlist(vartype(m.obj), T_OBJECT) endif return inlist(vartype(m.obj), T_OBJECT) ; and pemstatus(m.obj, 'BaseClass', 5) ; and ( proper(m.obj.BaseClass) == proper(m.BaseClassName) ) endfunc *_______________________________________________________________________________ function _DebugOut(prog_name,PARAMETERLIST_24) local s, i p = pcount() s = '' for i = 2 to pcount() s = s + ',' + transf(eval('m.p' + padl(m.i-1, 2, '0'))) endfor s = Proper(m.prog_name) + '(' + substr(m.s, 2) + ')' acti screen ? datetime(), ' ', m.s endfunc *_______________________________________________________________________________ *=============================================================================== *=============================================================================== *=============================================================================== define class TheColumnBinder as custom *_______________________________________________________________________________ protected function Init() local success success = true do case case !m.success case !DoDefault() assert false success = false case !inlist(type('m.this.Parent'), T_OBJECT) assert false success = false case !IsObject(m.this.Parent, 'Column') assert false success = false case !inlist(type('m.this.Parent.Parent'), T_OBJECT) assert false success = false case !IsObject(m.this.Parent.Parent, 'Grid') assert false success = false case !m.this.BindEvents() assert false success = false endcase return m.success endfunc *_______________________________________________________________________________ #if false Unbind all events where we are involved #endif protected function Destroy() _SHOW, m.this.Name try =UnbindEvents(m.this) catch endtry endfunc *_______________________________________________________________________________ protected function BindEvents() local success success = true do case case !m.success otherwise with m.this.Parent && Column local i, obj for i = 1 to .ControlCount obj = .Controls(m.i) do case case isObject(m.obj, 'Header') =BindEvent(m.obj, 'MouseDown', m.this, 'HeaderMouseDown', 1) =BindEvent(m.obj, 'Click', m.this, 'HeaderClick', 1) case IsObject(m.obj, 'Textbox') =BindEvent(m.obj, 'DblClick', m.this, 'TextboxDblClick', 1) endcase endfor endwith endcase return m.success endfunc *_______________________________________________________________________________ protected function HeaderMouseDown(nButton, nShift, nXCoord, nYCoord) _Show, m.this.Parent.Name =AddProperty(m.this.Parent.Parent, 'origcolnum', m.this.Parent.ColumnOrder) endfunc *_______________________________________________________________________________ protected function HeaderClick() _Show, m.this.Parent.Name #if false I do not see why you test : IF this.Parent.Parent.origcolnum = this.Parent.ColumnOrder imo, the MouseDown sets origcolnum. And since a Click always follows a MouseDown, I think that the test is not necessary Still, I've added the test #endif do case case !inlist(vartype(m.this.Parent.Parent.origcolnum), T_NUMERIC) case (m.this.Parent.Parent.origcolnum <> m.this.Parent.ColumnOrder) otherwise =m.this.Parent.parent.SortGrid(this.Parent) endcase endfunc *_______________________________________________________________________________ protected function TextboxDblClick() local aa[1] if( aEvents(aa, 0) == 3 ) _SHOW =AddProperty(m.this.Parent.Parent, 'filtercolumn', m.aa[1]) =m.this.parent.parent.DblClick() =AddProperty(m.this.Parent.Parent, 'filtercolumn', null) endif endfunc *_______________________________________________________________________________ enddefine *=============================================================================== *=============================================================================== *===============================================================================