*---------------------- Location Section ------------------------ * Library: Acustomcontrols.vcx * Class: Grdsorting * Method: Init() *----------------------- Usage Section -------------------------- *) Description: (ideas from message #946490 by Barbara Peisch) *) * Scope: Public * Parameters: *$ Usage: *$ * Returns: *--------------------- Maintenance Section ---------------------- * Change Log: * CREATED 01/06/2005 - NN * MODIFIED 01/10/05 - JMW Changed the variable names to * Hungarian notation. * MODIFIED 03/11/2005 - NN *---------------------------------------------------------------- if not dodefault() return .f. endif local loColumn, loControl * Delegate header's click to grid's HeaderClick custom method * and column's textbox DblClick to grid's DblClick for each loColumn in this.columns m.loColumn.addproperty("cOriginalControlSource", m.loColumn.controlsource) for each loControl in m.loColumn.controls if upper(m.loControl.baseclass) = "HEADER" bindevent(m.loControl,"Click",this,"HeaderClick") m.loControl.addproperty("CurrentTag","") && Adds CurrentTag property if this.lCreateIndexes && Adds indexes on the fly this.CreateTag (m.loControl) endif else if upper(m.loControl.baseclass) = "TEXTBOX" bindevent(m.loControl,"DblClick",this,"DblClick") endif endif endfor endfor if this.lManualHighlight local lcDynamicBackColor, lcDynamicForeColor lcDynamicBackColor = "iif(recno(this.RecordSource)=this.nRecno,this.HighlightBackColor,this.BackColor)" lcDynamicForeColor = "iif(recno(this.RecordSource)=this.nRecno,this.HighlightForeColor,this.ForeColor)" this.setall("DynamicBackColor", m.lcDynamicBackColor, "Column") this.setall("DynamicForeColor", m.lcDynamicForeColor, "Column") this.highlightstyle = 0 endif if this.lSaveGridProperties this.SaveGridProperties() endif
*---------------------- Location Section ------------------------ * Library: Acustomcontrols.vcx * Class: GrdSorting * Method: HeaderClick() *----------------------- Usage Section -------------------------- *) Description: Custom method which fires when Header is clicked (idea from Barbara Peisch) *) * Scope: Public * Parameters: *$ Usage: *$ * Returns: *--------------------- Maintenance Section ---------------------- * Change Log: * CREATED 01/06/2005 - NN * MODIFIED *---------------------------------------------------------------- local loCalledBy && as Object aevents[aCurEvent,0] loCalledBy = aCurEvent[1] && should be a Header object if vartype(m.loCalledBy)= "O" and not empty(m.loCalledBy.parent.cOriginalControlSource) local lcOrder, lcRecSource, llDirection lcRecSource = this.recordsource llDirection = this.lAscending lcOrder = order(m.lcRecSource) && Saves current tag this.SetOrder(m.loCalledBy.parent.cOriginalControlSource, m.loCalledBy.CurrentTag) if this.lShowSortingArrows * Check, if we changed the order if not order(m.lcRecSource)== m.lcOrder or m.llDirection <> this.lAscending ** Clear the picture of the previously sorted column m.loCalledBy.CurrentTag = this.cTagName this.ClearHeaderPictures() this.SetHeaderPicture(m.loCalledBy) endif endif endif this.mousepointer = 0This should give you an idea how this could be done.