2

I'm trying to find out if VisualHint.SmartPropertyGrid.PropertyGrid will meet my needs for setting properties, and some of my properties are boolean values.

One of the parameters is

//   container:
//     The instance of an object containing the C# property displayed in this new
//     property.

So in general, I can just hand it a suitable object - but, booleans are value types, not objects.

In C#, the right syntax is to enter the container as typeof(bool). Is there any sensible way to do this in C++, or do I have to make my own bool object?

Konrad Rudolph
  • 530,221
  • 131
  • 937
  • 1,214
Melanie
  • 1,349
  • 2
  • 17
  • 27
  • There is a [Previous answer][1] on the site [1]: http://stackoverflow.com/questions/351845/finding-the-type-of-an-object-in-c – JNF May 01 '12 at 07:41
  • In C++ the built in types do not have an alternate object representation. If you need one, but the `bool` in a `struct`. – Bo Persson May 01 '12 at 08:23
  • For the benefit of anyone else using a SmartPropertyGrid, I was asking the wrong question. The container can be `this`, where `this` has a `public: property bool boolprop` and then the membername is set to `"boolprop"`. – Melanie May 02 '12 at 01:23

1 Answers1

8

The exact equivalent of C#'s typeof operator is provided in C++/CLI by the typeid operator:

Type^ t = bool::typeid;
Hans Passant
  • 922,412
  • 146
  • 1,693
  • 2,536