locked
Using dynamicbold property in a class. RRS feed

  • Question

  • I have a class for "item_no"

    I drop this in grid columns and it has some functionality, among which is a doubleclick to edit a comment for that itemno.

    I would like the font to turn bold if there is a comment entered.

    The problem is that I can't check this because during init, the file may not be open in the different forms the class is used.

    Can someone suggest the best way to check for this at the class level?

    I hope I make myself clear.

    Thanks!

    Tuesday, September 17, 2019 3:58 AM

Answers

  • Hi Aleniko2,

    you will have to take care, that you get the info you need is read at the same time as the regular grid data is selected.

    Based on your description, there is 1 record in your basic grid table data and 1 or zero record with a comment to such a record. Such data constructs are accessed with left outer joins. However, sometimes the programmers use a simple non-normalized way of doing this, by placing the comment column into the same table, accepting that the column will mostly be empty. Since there are varchar fields this might have become even more appealing.

    Returning to the normalized version I assume that you store your comment data with a joinable table that contains 1 or more reference fields to make the join possible.

    Using this additional table with your grid may become a bit problematic, if you assign your data with a simple USE of the table. IMHO in that case there is no way to join the second table.

    What you could do is to create a view on both of the tables and later on USE this view to assign this artificial combined data table for your grid.

    In VFPs help there is a rather big section about views and  how to create,  manage, change, access them and many more. You should definetely have a look at this.

    JM2C


    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

    • Marked as answer by Aleniko2 Thursday, October 31, 2019 3:51 AM
    Tuesday, September 17, 2019 5:43 AM
    Answerer
  • Hello,

    Tom's description is a good way to handle that.

    We use a different way. We have classes based on container which holds labels, pictures, check boxes, whatever.

    The grid cursor holds only a pk of the main data. In backstyle_access() of the container the data is gathered and set to labels.caption,..

    Example

    Basecursor has pk_adr in column1 and pk_order in column2.

    Backstyle_access() of the container takes PK , seeks for that in table adr (or selects from mssql) , scatters some fields and set label captions to their contents. Same with order in columns2.

    Pseudocode for containr in column1

    m.npkdk = Evaluate(This.Parent.ControlSource)

    sele adr

    seek m.npkdk

    this.label1.caption = adr.nname

    If empty(adr.plz)

     this.label2.caption = "NO PLZ"

     this.label2.fontbold = .t.

    endif

    For speed we sometimes put data in grid cursor with joins/views, so no need for seeks,..

    Based on values we change label color / bold / underline / font in backstyle_access(), too.

    HTH

    Best regards

    tom


    • Edited by tom knauf Tuesday, September 17, 2019 7:44 AM
    • Marked as answer by Aleniko2 Thursday, October 31, 2019 3:51 AM
    Tuesday, September 17, 2019 7:41 AM

All replies

  • Hi Aleniko2,

    you will have to take care, that you get the info you need is read at the same time as the regular grid data is selected.

    Based on your description, there is 1 record in your basic grid table data and 1 or zero record with a comment to such a record. Such data constructs are accessed with left outer joins. However, sometimes the programmers use a simple non-normalized way of doing this, by placing the comment column into the same table, accepting that the column will mostly be empty. Since there are varchar fields this might have become even more appealing.

    Returning to the normalized version I assume that you store your comment data with a joinable table that contains 1 or more reference fields to make the join possible.

    Using this additional table with your grid may become a bit problematic, if you assign your data with a simple USE of the table. IMHO in that case there is no way to join the second table.

    What you could do is to create a view on both of the tables and later on USE this view to assign this artificial combined data table for your grid.

    In VFPs help there is a rather big section about views and  how to create,  manage, change, access them and many more. You should definetely have a look at this.

    JM2C


    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

    • Marked as answer by Aleniko2 Thursday, October 31, 2019 3:51 AM
    Tuesday, September 17, 2019 5:43 AM
    Answerer
  • Hello,

    Tom's description is a good way to handle that.

    We use a different way. We have classes based on container which holds labels, pictures, check boxes, whatever.

    The grid cursor holds only a pk of the main data. In backstyle_access() of the container the data is gathered and set to labels.caption,..

    Example

    Basecursor has pk_adr in column1 and pk_order in column2.

    Backstyle_access() of the container takes PK , seeks for that in table adr (or selects from mssql) , scatters some fields and set label captions to their contents. Same with order in columns2.

    Pseudocode for containr in column1

    m.npkdk = Evaluate(This.Parent.ControlSource)

    sele adr

    seek m.npkdk

    this.label1.caption = adr.nname

    If empty(adr.plz)

     this.label2.caption = "NO PLZ"

     this.label2.fontbold = .t.

    endif

    For speed we sometimes put data in grid cursor with joins/views, so no need for seeks,..

    Based on values we change label color / bold / underline / font in backstyle_access(), too.

    HTH

    Best regards

    tom


    • Edited by tom knauf Tuesday, September 17, 2019 7:44 AM
    • Marked as answer by Aleniko2 Thursday, October 31, 2019 3:51 AM
    Tuesday, September 17, 2019 7:41 AM
  • thanks both.
    Wednesday, September 18, 2019 10:14 PM
  • Hi,

    Have you solved this problem now?

    I think the above reply can provide you with a solution, have you tried it?

    If so, hope you can close this thread by marking the reply as answer as this will help others looking for the same or similar issues down the road.

    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, September 19, 2019 2:11 AM
  • Yes. Thanks!
    Thursday, October 31, 2019 3:51 AM