Jump to content
  • Advertisement
Sign in to follow this  
JohnHurt

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

This topic is 4038 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
Advertisement
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
Brilliant, that works a treat! My colour properties have colour selection controls now too! Thanks a million.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!