Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to double-click on a grid, to get its cell value
Message
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows XP
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01108948
Message ID:
01321091
Views:
32
>>Hi, all,
>>
>>My grid is created based on a query launched during the load() event of the form. Thus, the grid has no edit/properties parameters at design time, since the number of columns change, based on the number of fields on the cursor.
>>
>>My intention is to double-click on a cell on a grid, and get the value for further calculations.
>>
>>I realise that dblclick() does not work even for a pre-designed grid, and each textbox in each column has to have code attached to it individually in the dblclick()
>>
>>How do I attach this code interactively for a grid such as mine, with variable columns?
>>
>>Thanks,
>>
>>Regards,
>>
>>Steve.
>
>*---------------------- 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 = 0
>
>
>This should give you an idea how this could be done.

So I would have to create a function that sets enabled=.f., then reference it?
"Build a man a fire, and he's warm for a day.
Set a man on fire, and he's warm for the rest of his life."
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform