You can't add a column, where you want to store something, even just a logical .t./.f. in a checkbox, without having a table field for it.
The grid is always driven by one table/cursor/alias. What you can do is relate a further table or cursor with the main one and displpay and edit fields of that further table.
That's an advanced technique and nothing I would recommend to you, as long as I don't know how deep your knowledge goes. Since you have some rather basic question I think that is too complicated for now.
There is a simple way around to add a field with a query, so you
select table.*, .F. as Selected from table into cursor curGrid Readwrite
Now you can bind to that cursor and let your checkbox be bound to the Selected field, which was generated by the SQL query with a default constant value of .F. for all records.
If you are looking for a control allowing multiple selections from a list of records, the listbox would be appropriate in it's multi select mode (you set Listbox1.MultiSelect=1). There is no need for an additional column and field in case you make use of that. But I admit you are not the first one trying to accomplish the same thing with a checkbox inside an additional grid column. It has it's pros and cons. For one, multi select in a listbox works like selection of multiple files in windows explorer with SHIFT and CTRL key in combination with clicks, a checkbox is more intuitive, even though windows users had quite some time to learn how multi select works in windows.
I think the core problem you had was to fill a further column, as said you can't, but you can easily add a further field to a query result. You can't use an unbound column of a grid, as the grid does not have a control per row, it only has one control for each column, just the current, active row is real, all other grid rows were drawn with the data of other records. To display different values there need to be differernt records, so an unbound column with a checkbox could only display all checked or unchecked in a grid, you have to store the different values in some field, as vfp can't store the different values in check1,check2,check3, etc. there only is check1.
When dealing with a grid, it helps if you think of it this way:
Look out the window in your house. You can see what is outside. You can close the curtains or blinds part way and still see some of what's outside, but the window can't change what's outside. It just changes how much of the outside you see. A grid does not contain data. It's simply a window sitting on top of a cursor, table, or view (which themselves are basically all the same). If data doesn't exist in the cursor, the grid can't show it to you, but it can affect how much of the data you see. So the grid is much like the window in your house.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.