Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > ActiveX COM > Property Grid
  New Posts New Posts RSS Feed - No Grayed Text for Read Only Items
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

No Grayed Text for Read Only Items

 Post Reply Post Reply
Author
Message
Boyd View Drop Down
Senior Member
Senior Member


Joined: 08 December 2003
Location: United States
Status: Offline
Points: 285
Post Options Post Options   Thanks (0) Thanks(0)   Quote Boyd Quote  Post ReplyReply Direct Link To This Post Topic: No Grayed Text for Read Only Items
    Posted: 24 February 2004 at 9:49am

The Properties Grid displays Read Only items in a "grayed" font color.  This is helpful when you need to visually distinguish between items that can be modified and items that are read only.

I have a need to create a property grid that is entirely read only.  Since all items are read only, they all appear in "grayed" text.  Since the "grayed" text can sometimes be harder to read, I would like to be able to disable the "graying" of read-only items.  If this cannot be done in 8.61, could you possible add a feature to the control in 8.62 to allow for this?  Either a flag that disables the special drawing of read-only items or a property that lets you specify the fore color of those items.

Thank you again!

Back to Top
SuperMario View Drop Down
Admin Group
Admin Group
Avatar

Joined: 14 February 2004
Status: Offline
Points: 18057
Post Options Post Options   Thanks (0) Thanks(0)   Quote SuperMario Quote  Post ReplyReply Direct Link To This Post Posted: 24 February 2004 at 10:39am
No, I am sure there is no way to get rid of the "grey" in a read only property.  All I do to work around this is add the item as a constraint and set the ConstraintEdit = True, which keeps them from editing the text.  The code below has a property called Operating System that will have three items to chose from.  The user can only read the text, they can not change the values.  But they can still select between the three choices.  If you have only one item to display, then add it as a constraint and set no flags. 

    Dim Category As IPropertyGridItem
    Dim Item As IPropertyGridItem
    
    Set Category = wndPropertyGrid.AddCategory("Platform")
    Set Item = Category.AddChildItemBinded(PropertyItemString, Me, "Operating System")
    Item.Constraints.Add "Windows XP"
    Item.Constraints.Add "Windows 2000"
    Item.Constraints.Add "Windows 98"
    Item.ConstraintEdit = True
    Item.Flags = ItemHasComboButton

This will appear to the user as read only.


Edited by SuperMario
Back to Top
Boyd View Drop Down
Senior Member
Senior Member


Joined: 08 December 2003
Location: United States
Status: Offline
Points: 285
Post Options Post Options   Thanks (0) Thanks(0)   Quote Boyd Quote  Post ReplyReply Direct Link To This Post Posted: 24 February 2004 at 11:01am

Great suggestion, SuperMario.  Thanks!  I only have 1 item to display, so I obviously didn't set the flag for ItemHasComboButton and it worked.  It turns out that even if there is only one item in the Constraint list, the drop-down arrow is still displayed.

While this is a good workaround, it's a few extra lines of code to implement it.  I hope that Codejock will still consider providing an option to control how read only items are displayed.

Back to Top
SuperMario View Drop Down
Admin Group
Admin Group
Avatar

Joined: 14 February 2004
Status: Offline
Points: 18057
Post Options Post Options   Thanks (0) Thanks(0)   Quote SuperMario Quote  Post ReplyReply Direct Link To This Post Posted: 24 February 2004 at 11:07am
Opps, that was supposed to read " If you have only one item to display, then add it as a constraint and set no flags."  I edited the original post so noone else gets confused.
Back to Top
Boyd View Drop Down
Senior Member
Senior Member


Joined: 08 December 2003
Location: United States
Status: Offline
Points: 285
Post Options Post Options   Thanks (0) Thanks(0)   Quote Boyd Quote  Post ReplyReply Direct Link To This Post Posted: 07 April 2004 at 1:58pm

SuperMario,

I have a small follow-up on this technique that prevents it from being a total solution.  Even if you use this technique, the user can right-click on the value and "Paste" a value.

Any chance this can be fixed for the 8.70 release?

Back to Top
hd3810 View Drop Down
Newbie
Newbie


Joined: 01 June 2004
Status: Offline
Points: 1
Post Options Post Options   Thanks (0) Thanks(0)   Quote hd3810 Quote  Post ReplyReply Direct Link To This Post Posted: 01 June 2004 at 8:15pm

Hi,

thanks for the great example. i have tried to look up AddChildItemBinded in the documentation and did not find much description. can someone please share the usage instruction of this function? what is the purpose of this function? what is the "Handler" parameter?

thanks so much.

Back to Top
SuperMario View Drop Down
Admin Group
Admin Group
Avatar

Joined: 14 February 2004
Status: Offline
Points: 18057
Post Options Post Options   Thanks (0) Thanks(0)   Quote SuperMario Quote  Post ReplyReply Direct Link To This Post Posted: 02 June 2004 at 6:50am
AddChildItemBinded is used to store the value of your property grid items in variables that can be used by other subroutines and functions in your application.  This "binds" the property grid item to a variable, when the value of the property grid item is changed, the variable is updated.   Binding only occurs in one direction, that is, when you change the value of a property grid item via the grid, the value of the variable is updated.  However, if you change the value of the variable witholut using the grid, the property grid item will not be updated, you would need to manually update the property grid item to reflect the change.

The "Handler" parameter is the form that has the variable that the property grid is bound to.  You can not bind to variables in modules, the variables must be included within an objects code.

The "Property" parameter is the name of the variable in "string notation"  this mean you pass the name of the variable the property grid item will be bound to and it can have spaces and upper/lower case letters.  This will appear at the caption for the property grid item unless you manually change the caption of the property grid item.

Hope this helps
Back to Top
SuperMario View Drop Down
Admin Group
Admin Group
Avatar

Joined: 14 February 2004
Status: Offline
Points: 18057
Post Options Post Options   Thanks (0) Thanks(0)   Quote SuperMario Quote  Post ReplyReply Direct Link To This Post Posted: 19 October 2004 at 1:04pm
I thought you all might want to know that a new property, PropertyGrid::ViewReadOnlyForeColor, has been added (I'm not sure if this is in 9.51).  This allows you to set the color of the text for ReadOnly items. 
Back to Top
Boyd View Drop Down
Senior Member
Senior Member


Joined: 08 December 2003
Location: United States
Status: Offline
Points: 285
Post Options Post Options   Thanks (0) Thanks(0)   Quote Boyd Quote  Post ReplyReply Direct Link To This Post Posted: 19 October 2004 at 1:24pm
Thanks.  I was told by Oleg that this will be in the next release after 9.51.
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.141 seconds.