Sign in to follow this  

[.net] Binding C++/CLI class to PropertyGrid

This topic is 3845 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm trying to bind a class to a PropertyGrid control so that I can change its attributes. Specifically, I'm making a simple particle system editor. I have the class bound to the control and all the properties are showing up. The problem is that only the properties defined as String are enabled, the other properties are greyed out and read-only. Here's the code for the class:
public ref class cParticleDef
{
private:
        String^ fEmissionRate;
        Boolean^ bCanStretch;
public:

	[Category("Configuration")]
	[Description("Rate of emission")]
	property String^ EmissionRate
	{
		String ^ get() { return fEmissionRate; }
		void set(String ^ value) 
		{
			fEmissionRate = value; 
		}
	};

	[Category("Appearance")]
	[Description("Sets whether the particles can stretch along velocity vector")]
	property Boolean^ CanStretch
	{
		Boolean ^ get() { return bCanStretch; }
		void set(Boolean ^ value) 
		{
			bCanStretch = value; 
		}
	};
};



Also, the boolean property doesn't produce a drop-down control in the PropertyGrid. I'm very new to managed code and .net, so it's probably something really stupid, so I'd appreciate a fresh pair of eyes!

Share this post


Link to post
Share on other sites
Is there a reason you're using Boolean^ and not Boolean or just bool? Boolean is a value type, so you don't need to make a reference to it; maybe that's what's confusing the property grid.

Share this post


Link to post
Share on other sites

This topic is 3845 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this