Print Page | Close Window

How to use AddChildItemBinded in C#?

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=10674
Printed Date: 07 July 2024 at 9:50pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: How to use AddChildItemBinded in C#?
Posted By: leojay
Subject: How to use AddChildItemBinded in C#?
Date Posted: 19 May 2008 at 12:03am
I'm using c#.

I define a field named nData, and a property named Data like this:
        private int nData = 0;
        public int Data
        {
            get { return nData; }
            set
            {
                nData = value;
                System.Diagnostics.Debug.WriteLine(nData);
            }
        }


in the Form_Load function:
            XtremePropertyGrid.PropertyGridItem root = PropertyGrid.AddCategory("a");
            root.AddChildItemBinded(XtremePropertyGrid.PropertyItemType.PropertyItemNumber, this, "nData");


but the second line of the Form_Load code snippet throws an InvalidCastException, and says "Specified cast is not valid".

if  i change the third parameter of the second line to "Data", I still get the same error.

so, my question is, is it possible to use AddChildItemBinded in C#?
If it's possible, any sample available?

thanks.



Replies:
Posted By: Oleg
Date Posted: 19 May 2008 at 1:35am
Hi,
 
Just tried with vc2002 and vc2008 - your code works.
 
Can you modify our sample and attach it here.


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


Posted By: leojay
Date Posted: 19 May 2008 at 3:27am
you can get my project here:
http://python.leojay.googlepages.com/pgtest.zip

it's strange that, in your PropertyGrid sample, my code works.
but in a new project, it doesn't.
i don't know why. :(


Posted By: Oleg
Date Posted: 20 May 2008 at 3:17am
Hi,
 
Change this:
 
Properties->Application-> Assembly Information:
Click Checkbox "Make assembly COM-Visible"
 
and instead of "nData" specify public "Data"


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


Posted By: leojay
Date Posted: 20 May 2008 at 4:02am
thanks, that works.

is it possible to add some specific description in the thrown exception?
"Specified cast is not valid" is really not a good hint.


Posted By: Oleg
Date Posted: 20 May 2008 at 8:11am
Hi,
 
its .NET description not our :)


-------------
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