Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Grid Currentcontrol and sparse
Message
 
 
To
08/07/2015 10:33:48
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Desktop
Miscellaneous
Thread ID:
01621870
Message ID:
01621871
Views:
55
>In a grid's column I add a container object to display some special formatted data (a rating from 1 to 100). However when setting the column's sparse property to .F. it displays the same data for all rows, although there are different values in each row.
>
>If I set Sparse to .T. then it does display the different values, however when the cell does not have the focus it does not display the added container object but the normal textbox with the plain value. I understand this is what the Sparse property is supposed to do, but is it possible in a grid to have a custom container object visible at all times with the data showing the individual rows? If it were only up to 10 different possible values I could use DynamicCurrentControl but there can be up to 100 different values (range from value 1 to 100).

Yes, it's possible. Here is how it works in one of my forms.

Form's Init:
scan
		if proper(alltrim(LanguageCol)) = 'Language00'
		else

			.grdLanguages.columncount = .grdLanguages.columncount + 1
			lnCount = .grdLanguages.columncount
			with .grdLanguages.columns[m.lnCount]
				.name = 'col' + alltrim(csrLanguages.LanguageCol)
				.width = m.lnWidth
				.sparse = .f.
				.removeobject('text1')
				.newobject('cntLanguage','cntLanguage','Languages.vcx')
				.cntLanguage.visible = .t.
				.cntLanguage.lngField = 'Language.' + alltrim(csrLanguages.LanguageCol)
				.Header1.caption = alltrim(csrLanguages.language)
				.Header1.fontbold = .t.
				.Header1.alignment = 2
			endwith
		endif
	endscan
cntLanguage consists of a textbox with a translation text and a button to invoke the form to change the value. It has the lngField_Assign method with the following code:
lparameters tlngField
This.lngField = tlngField
this.txtLanguage.ControlSource = this.lngField
The button has the following code although this is probably irrelevant to your situation.
LOCAL lcNewValue as String, lcOldValue as String 
lcOldValue = EVALUATE(this.parent.lngField) 
thisform.SetToolbarsEnabledTo(.F.) 
DO FORM Response_Edit WITH m.lcOldValue, 'Translation Edit' TO lcNewValue
thisform.SetToolbarsEnabledTo(.T.) 
IF NOT m.lcNewValue == m.lcOldValue
	this.Parent.txtLanguage.Value = m.lcNewValue
	this.Parent.txtLanguage.Refresh()
endif
So, it seems to me that simple assign method does this trick.

Language is the alias of the table which is a RecordSource for the grid.
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform