Skip to main content
GameDev.net gamedev.net
🔒 Locked

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

Started by JohnHurt Jun 2, 2007 at 11:49 AM 2 replies 5.8k views
Original Post
JohnHurt
JohnHurt
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!
vermilion_wizard
vermilion_wizard
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.
JohnHurt
JohnHurt
Ah, that could be it. Will have a crack at that later on this week and report back.
JohnHurt
JohnHurt
Brilliant, that works a treat! My colour properties have colour selection controls now too! Thanks a million.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.