locked
Grid Checkbox Not Visible RRS feed

  • Question

  • I added checkboxes in 2 columns for logic fields. They are visible on the form's grid in the Form Designer but do not show when run.

    The data shows T or F correctly in the columns, but the checkboxes are not visible.

    The column's CurrentControl is set to the checkbox.

    I tried changing the Sparse property and even removed the textbox control from the column. The checkbox is listed in the properties list, but when run, it acts as if the textbox is still there even though it NOT listed in the properties list.

    If I reference the checkbox in the program (THISFORM.MyGrid.Column1.Check1), it throws the error  "Unknown member Check1".

    What am I missing here?

    Steve

    Sunday, September 29, 2019 6:40 PM

Answers

  • Hm, I don't make use of the cursor/tablename within the controlsource. The cursorname is defined within the grid's recordsource and therefore has no need to be named again within the controlsource.

    But you probably do this for your complete grid and not only for the checkboxes. SO it would make the situation even more weird.

    How about deleting the grid and building it from scratch? But I assume, that you tried that already, right? :)

    Hopefully you find out why it happens and tell us the solution.


    Gruss / Best regards
    -Tom
    Debugging is twice as hard as writing the code in the first place.
    Therefore, if you write the code as cleverly as possible,
    you are, by definition, not smart enough to debug it. 010101100100011001010000011110000101001001101111011000110110101101110011

    Tuesday, October 1, 2019 5:24 AM
    Answerer

All replies

  • Hi Steven,

    is it possibly, that your table/cursor doesn't exist at that time, where your grid is build during runtime?

    Usually I get such a behaviour as soon as the grid cannot access its assigned data construct or when rebuilding the grids assigned cursor at a later time, without temporarily assigning an interims cursor with an identical data structure.

    This usually leads to a complete recreation of the grid based on its regular grid/column/header/text hierarchy.

    HTH


    Gruss / Best regards
    -Tom
    Debugging is twice as hard as writing the code in the first place.
    Therefore, if you write the code as cleverly as possible,
    you are, by definition, not smart enough to debug it. 010101100100011001010000011110000101001001101111011000110110101101110011

    Monday, September 30, 2019 10:33 AM
    Answerer
  • Thanks, Tom.

    The grid's properties are assigned right AFTER the table is created.

    I may be adding the checkbox incorrectly, but the checkboxes do show in the columns in the form designer. For example the first one is listed as CkPick under Column1 in the properties list. HOWEVER, if I reference it as THISFORM.MyGrid.Column1.CkPick, it still throws the error  "Unknown member CkPick". I can't seem to have the program recognize the checkbox objects.

    Steve

    Monday, September 30, 2019 12:48 PM
  • I haven't tried renaming any object that I used to replace the regular text1 with.

    I let VFP do the work and let it select a proper name it likes to work with :) Therefore all my checkboxes are named 'check1' 8)

    in this form that I just finished there is the typical check1 with column.sparse=.F. and everything is working fine.

    As we don't make use of booleans in our tables, the checkbox references an integer column, but this shouldn't make a difference as checkboxes can work with both.

    However, I create a temporary cursor for the grid in form.load that is used in the grid.recordsource already at designtime. Each column as a predefined controlsource based on the cursors column names. And as soon as the filterproperties have been set and the ReadData method has fetched the real data, I assign this new cursor that is (btw) identical in its structure as the temp one.

    So, what went wrong in your form?

    How did you place your checkbox in the grid column?

    The way I do this is, to remove the text1 textbox first by selecting it in the properties window, then activating the form itself by clicking the VFP form caption. That way the focus stays on the text1 object (though this isn't recognizable), and pressing the DEL key on my keyboard.

    Now I mark the checkbox in the objects toolbar and click into the column that shall receive the checkbox. Now the column holds a new checkbox as 'check1' and the checkbox is automatically set as currentcontrol as if it had always been there.

    Hopefully you didn't do it that way, so we may have found where something might have gone wrong :)


    Gruss / Best regards
    -Tom
    Debugging is twice as hard as writing the code in the first place.
    Therefore, if you write the code as cleverly as possible,
    you are, by definition, not smart enough to debug it. 010101100100011001010000011110000101001001101111011000110110101101110011


    Monday, September 30, 2019 1:58 PM
    Answerer
  • Hi Tom,

    I created the checkboxes EXACTLY as you described. The properties sheet (couldn't copy it) looks like:

    Grid1

        Column1

            Header1

            Check1

        Column2

            Header1

            Check1

    Checkboxes show in form designer:

    Checkboxes don't show when run:

    The rest of the 15 fields display perfectly when run.

     THISFORM.Grid1.Column1.ControlSource='Results.Picked' && Is ok

     THISFORM.Grid1.Column1.Check1.ControlSource='Results.Picked' &&

    throws error "Unknown member Check1". Apparently, VFP still thinks it's a textbox.

    Note: I create Results.dbf JUST BEFORE I set the grid properties.

    The weird thing is the checkboxes showed one time right after I renamed the grid to Grid1, but never again. Not sure what I did, if anything.

    I may try some more stuff or figure a workaround.

    Thank you very much for your suggestions.

    Steve

    Monday, September 30, 2019 11:39 PM
  • Hm, I don't make use of the cursor/tablename within the controlsource. The cursorname is defined within the grid's recordsource and therefore has no need to be named again within the controlsource.

    But you probably do this for your complete grid and not only for the checkboxes. SO it would make the situation even more weird.

    How about deleting the grid and building it from scratch? But I assume, that you tried that already, right? :)

    Hopefully you find out why it happens and tell us the solution.


    Gruss / Best regards
    -Tom
    Debugging is twice as hard as writing the code in the first place.
    Therefore, if you write the code as cleverly as possible,
    you are, by definition, not smart enough to debug it. 010101100100011001010000011110000101001001101111011000110110101101110011

    Tuesday, October 1, 2019 5:24 AM
    Answerer
  • Yes, I rebuilt it from scratch. And yes, I set the control source for each column in addition to setting it for Grid1. That may be the problem. I'll see & get back.


    Tuesday, October 1, 2019 1:08 PM
  • Hi,

    Do you resolve the issue? If you resolve the issue, please mark the helpful as answer. It will be beneficial to other community.

    Best Regards,

    Julie


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, October 3, 2019 7:23 AM
  • No, the issue is not completely resolved, but I'll figure it out eventually. You can close it out though, for now. Thanks.

    Steve

    Thursday, October 3, 2019 5:50 PM
  • Progress: The checkboxes show, but only the first time the program is run in IDE after opening VFP. The checkboxes do not show when the program is closed and rerun before exiting VFP. I have not tried it in exe.

    Steve


    Thursday, October 3, 2019 7:48 PM
  • I found a solution. Placing CLOSE DATABASES in the Destroy method allowed the checkboxes to appear in following runs without having to exit VFP.

    I had CLOSE DATABASES in the Init() method, but it does not produce the same result. Don't know why.

    Steve

    Friday, October 4, 2019 1:15 PM