>Wanted to center a checkbox in a grid. Made a class of a container with a checkbox so that I could set the check.left property to center the checkbox within the container.
>
>My grid is bound to a table. All the checkboxes are used for logical fields. The column1.spare is set to .F.
>
>I have no code in my container_grid class. After adding the container_grid class to the column of the grid, I set the check1.controlsource in the check1.init to the correct table.fieldname. When I run the app, I get really goofy results. The checkbox has no values, until the grid gets focus. Then when I check on check1 - check2 (another checkbox in a different column) checks or unchecks. What am I missing?
>
>Brenda
In the INIT of the container of my GridCheckBox class, I put:
This.ChkBox.ControlSource = This.Parent.ControlSource
This refers to the container, and
This.Parent refers to the grid column. So all I have to do is make sure the Column ControlSource is properly defined. I, of course, changed the name of the checkbox in the container to ChkBox and blanked the Caption property.
I also have Resize code to size the container then center the checkbox in the container.
if upper(This.Parent.Parent.BaseClass) = "GRID"
with This
.Width = .Parent.Width
.Height = .Parent.Parent.RowHeight
.chkBox.Left = max(0, int((.Width - .chkBox.Width) / 2))
.chkBox.Top = max(0, int((.Height - .chkBox.Height) / 2))
endwith
endif
Mark McCasland
Midlothian, TX USA