Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Center Checkbox in a grid
Message
From
28/12/2001 11:47:37
 
 
To
28/12/2001 07:14:49
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
General information
Forum:
Visual FoxPro
Category:
FoxWeb
Miscellaneous
Thread ID:
00598708
Message ID:
00598834
Views:
18
>>Cetin,
>>
>>I'm trying to center a checkbox in a grid....I must be missing something on how to add the container and checkbox to the grid. One way and I get an error in the column.currentcontrol of "Expression evaluated to an illegal value". The other way, once I set the column.currentcontrol to the container, at runtime the checkbox is not found. What am I missing? Is there a special way of adding the checkbox to the container and then to the grid ??
>>
>>In the grid.init I have:
>>with this.column6
>>.container1.check1.controlsource=.controlsource
>>endwith
>>
>>In the container.init I have:
>>with this.check1
>>.Left=(this.parent.width-.width)/2
>>endwith
>>
>>Many thanks,
>>Greg
>
>Greg,
>If you create it as a class you'd be more comfortable.
>
>1) On a form put a Checkbox, remove caption size to check only and code this in Keypress (provides up/down arrow moving - and you could enhance for other keys as well):
>
>
Lparameters nKeyCode, nShiftAltCtrl
>With this.parent.parent.parent
>  lnRows = int((.Height - (sysmetric(8)+.HeaderHeight))/.RowHeight)
>  If nKeyCode = 24
>    Nodefault
>    If .RelativeRow = lnRows
>      .DoScroll(1)
>    Endif
>    .ActivateCell(.RelativeRow+1,.RelativeColumn)
>  Endif
>  If nKeyCode = 5
>    Nodefault
>    If .RelativeRow = 1
>      .DoScroll(0)
>    Endif
>    .ActivateCell(.RelativeRow-1,.RelativeColumn)
>  Endif
>Endwith
>
>
>2) Select this checkbox and save as a class (would be a container)
>In container init :
>
*Container.init
>with this
>  .Resize
>  .Check1.Controlsource = .Parent.Controlsource
>endwith
>
>*Container.resize
>with this.Check1
> .Left = (this.Parent.Width - .Width)/2
>endwith
>
>3) Remove temp checkbox from form, Right click on your grid and choose column that checkbox would be in.
>From form controls select your new classlib and checkboxclass (assume you named it grdChkBox). Click on grid column.
>
>4) In PEM sheet locate the column and change CurrentControl from its combo.
>If would do in code be sure to have quotes ("Expression evaluated to an illegal value" should be related with this). ie:
>
>thisform.myGrid.myColumn.Currentcontrol = 'grdChkBox'
>
>5) Set column sparse to .f.
>6) In column.resize code :
>this.grdChBox.resize
>
>PS: If you don't want to saveas a class then create a temp container on form, pu the checkbox in it, when you're doen with coding cut and put into column. Also set conatiner, checkbox backstyle to transtparent and containe rborderwith to 0 for a better vis7ual effect.
>
>If you have further questions lemme know.
>Cetin

Cetin,
Thanks for your help but I'm still doing something wrong....Below is the class code I created from your suggestion. When the program runs an error occurs saying "check1 not found". The check boxes show up but are not centered becasue of the error in the with/endwith statement.

DEFINE CLASS grdchkbox AS checkbox
Height = 13
Width = 12
Caption = ""
Name = "grdchkbox"

*-- Occurs when an object is resized.
PROCEDURE resize
WITH this.check1
.left=(this.Parent.Width-.width)/2
ENDWITH

ENDPROC


PROCEDURE Init
WITH this
.resize()
.check1.controlsource=.parent.controlsource
ENDWITH
ENDPROC


PROCEDURE KeyPress
LPARAMETERS nKeyCode, nShiftAltCtrl
WITH this.Parent.Parent.Parent
lnrows=INT((.height-(SYSMETRIC(8)+.headerheight))/.rowheight)
IF nKeyCode=24
NODEFAULT
IF .relativeview=lnrows
.doscroll(1)
ENDIF
.activatecell(.relativerow+1,.relativecolumn)
ENDIF
IF nKeyCode=5
NODEFAULT
IF .relativerow=1
.doscroll(0)
ENDIF
.activatecell(.relativerow-1,.relativecolumn)
ENDIF
ENDWITH


ENDPROC


ENDDEFINE

Any further thoughts on what I'm missing?
Greg
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform