Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Data type mismatch with Checkbox in grid
Message
From
26/05/2003 21:43:18
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Title:
Data type mismatch with Checkbox in grid
Miscellaneous
Thread ID:
00792917
Message ID:
00792917
Views:
56
Others have posted threads on here describing 'data type mismatch' when there is a checkbox in a grid. However, I think that most of the threads pertained to checkboxes in grids where the grid was defined at design time. I am building a grid programmatically. Now matter what I did, I would either get data type mismatch when I either a) clicked on the checkbox at runtime, or b) set the bound property to .t. for the column that the checkbox was in -programmatically - while building the grid.

For some inexplicable reason, the only way I got this to work was to first assign a numeric global variable as the control source to the column, while building the grid - then, after assigning the recordsource, reassigning the control source to my cursor's numeric field. Even though: a) my checkbox class has a 0 as the default and b) my cursor has a numeric value for the field that will be bound to the checkbox, I still get this data type mismatch problem. Inspecting the checkbox object in the debugger shows that it has a type of 'N'.

I'm glad it's working, but I feel as if the code is so fragile, because I really don't understand why. Can anyone shed some light? Here is a fragment of the code:


lcsqlnone= ' and (1 = 1) '

lcsqlstmt='select ' + alltrim(CurErptaggedlists_h.msqlselect) + ', 1.00 as ltagged '
lcsqlstmt=lcsqlstmt + ' from ' + alltrim(CurErptaggedlists_h.msqlfrom)
lcsqlstmt=lcsqlstmt + ' where ' + alltrim(CurErptaggedlists_h.msqlwhere) + lcsqlnone
lcsqlstmt = lcsqlstmt + ' order by ' + alltrim(CurErptaggedlists_h.morderby)
*activ screen
*suspen



lnresult=sqlexec(osystem.ncomhandle,lcsqlstmt,'Curtaggedlist')
*suspend
IF lnresult >= 1



LOCAL lnobjcntr, lcobjname

*-- note - going by lnobjcntr even though - could go by ncolumnno - in case ncolumnno is duped
lnobjcntr=0
assert .f.
DO while not eof('Curerptaggedlists_d')
lnobjcntr=lnobjcntr+1
lccolobjname='column' + alltrim(str(lnobjcntr))
this.grdtaggedlist.addobject(lccolobjname,"column")
lccontrolsource=alltrim(Curerptaggedlists_d.ccontrolso)
this.grdtaggedlist.&lccolobjname..controlsource=lccontrolsource
this.grdtaggedlist.&lccolobjname..currentcontrol="text1"
this.grdtaggedlist.&lccolobjname..visible=.t.
this.grdtaggedlist.&lccolobjname..width=Curerptaggedlists_d.nwidth
this.grdtaggedlist.&lccolobjname..header1.caption=alltrim(Curerptaggedlists_d.cheader)

Skip in Curerptaggedlists_d
ENDDO
lnobjcntr=lnobjcntr+1
this.grdtaggedlist.&lccolobjname..bound=.f.
*if I take out the line below- will get data type mismatch when I
** set bound to .t., or, if i don't set bound to .f. to begin with,
** will get data type mismatch when i click on the checkbox
** if I even 'think about' setting the value property of the *checkbox
*here, to zero or 1 - or setting it period to anydata - I get a C5 *error.
* somehow setting the controlsource to a global numeric first makes my *problem go away - don't ask me why i even thought of doing this - dumb luck
** just had a vague notion that vfp wasn't keeping the data type of the *control in scope

this.grdtaggedlist.&lccolobjname..controlsource=gnnumber

*this.grdtaggedlist.&lccolobjname..controlsource='curtaggedlist.ltagged'

this.grdtaggedlist.&lccolobjname..newobject('checkbox1','chkboxtag','satfilter')


*this.grdtaggedlist.&lccolobjname..bound=.f.
*this.grdtaggedlist.&lccolobjname..checkbox1.value=.f.

this.grdtaggedlist.&lccolobjname..checkbox1.caption=''

this.grdtaggedlist.&lccolobjname..currentcontrol="checkbox1"
this.grdtaggedlist.&lccolobjname..sparse=.f.

this.grdtaggedlist.&lccolobjname..visible=.t.
this.grdtaggedlist.&lccolobjname..width=Curerptaggedlists_d.nwidth
this.grdtaggedlist.&lccolobjname..header1.caption='Selected'

this.grdtaggedlist.&lccolobjname..bound=.t.
this.grdtaggedlist.recordsource='Curtaggedlist'
this.grdtaggedlist.&lccolobjname..controlsource='curtaggedlist.ltagged'





Next
Reply
Map
View

Click here to load this message in the networking platform