No Grayed Text for Read Only Items |
Post Reply |
Author | |
Boyd
Senior Member Joined: 08 December 2003 Location: United States Status: Offline Points: 285 |
Post Options
Thanks(0)
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! |
|
SuperMario
Admin Group Joined: 14 February 2004 Status: Offline Points: 18057 |
Post Options
Thanks(0)
|
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 |
|
Boyd
Senior Member Joined: 08 December 2003 Location: United States Status: Offline Points: 285 |
Post Options
Thanks(0)
|
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. |
|
SuperMario
Admin Group Joined: 14 February 2004 Status: Offline Points: 18057 |
Post Options
Thanks(0)
|
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.
|
|
Boyd
Senior Member Joined: 08 December 2003 Location: United States Status: Offline Points: 285 |
Post Options
Thanks(0)
|
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? |
|
hd3810
Newbie Joined: 01 June 2004 Status: Offline Points: 1 |
Post Options
Thanks(0)
|
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. |
|
SuperMario
Admin Group Joined: 14 February 2004 Status: Offline Points: 18057 |
Post Options
Thanks(0)
|
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 |
|
SuperMario
Admin Group Joined: 14 February 2004 Status: Offline Points: 18057 |
Post Options
Thanks(0)
|
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.
|
|
Boyd
Senior Member Joined: 08 December 2003 Location: United States Status: Offline Points: 285 |
Post Options
Thanks(0)
|
Thanks. I was told by Oleg that this will be in the next release after 9.51.
|
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |