Print Page | Close Window

AddChildItemBinded & ReadOnly Properties

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Property Grid
Forum Description: Topics Related to Codejock Property Grid
URL: http://forum.codejock.com/forum_posts.asp?TID=3598
Printed Date: 04 May 2024 at 10:09am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: AddChildItemBinded & ReadOnly Properties
Posted By: ianp
Subject: AddChildItemBinded & ReadOnly Properties
Date Posted: 03 February 2006 at 11:39pm

I'm having difficulty updating the value displayed by a propertygrid item which is bound to a readonly property.

Here is the code I used to add the bound item:

Set xpgItem = xpgCategory.AddChildItemBinded(PropertyItemNumber, oItems, "Count")
xpgItem.ReadOnly = True

If the value of oItems.Count subsequently changes, I need the PropertyGrid to display the new value, so (as per the documentation) I explicitly update the PropertyGridItem value with the contents of the variable:

wndPropertyGrid.FindItem("Count").Value = oItems.Count

However, when I do this, I get the following run-time error:

Quote Run-time error '451':

Property let procedure not defined and property get procedure did not return an object

Any ideas what I'm doing wrong?




Replies:
Posted By: Oleg
Date Posted: 04 February 2006 at 8:27am

Check that wndPropertyGrid.FindItem("Count") returns some object and not "Nothing".

 

If you don't set xpgItem.ReadOnly = True do you have this error?



-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: ianp
Date Posted: 05 February 2006 at 7:50am

Hi Oleg

TypeName(wndPropertyGrid.FindItem("Count")) = IPropertyGridItem
wndPropertyGrid.FindItem("Count").value = 1
oItems.Count = 2
TypeName(oItems) = clsItems

If I don't set the ReadOnly flag on the PropertyGridItem, then I get the same error when programmatically setting the value, or by typing the new value into the propertygrid using the keyboard.

The error message that appears is technically correct. oItems.Count is a Property, of type Long, defined with a Get and no Let or Set. (i.e. the Count property is a read only value which is set based on other properties within the oItems object)

Private colItems As Collection
Public Property Get Code() As Long
    If Not colItems Is Nothing Then
        Count= colItems.Count
    Else
        Counts= 0
    End If
End Property

Any other ideas, or should I just revert to a regular child item as I am only displaying this value for informational purposes and have no real need for this property to be bound?



Posted By: Oleg
Date Posted: 05 February 2006 at 10:00am
Think the problem that you bind the item to non "Long" property. Instead AddChildItemBinded use AddChildItem.

-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net