Notifications
Clear all

[Closed] (.NET) Property Grid

Hi All,
I’ve searched long and hard over the past few years for a decent, and hopefully free ActiveX property grid implimentation that would work hapily with MaxScript.

To be honest, I came up pretty empty-handed.

Does anyone know of an ActiveX one that actually works well with MXS, has support for most datatypes (including color) and is possibly hierarchical?

Here’s the kind of thing I’m talking about:

If not, does anyone know if there are any free, or built-in .NET ones?

Many thanks,
Dave Stewart

10 Replies

Hi Dave,

Yes, if you use 3ds Max 9 you have the built-in PropertyGrid control from .NET 2.0 Forms.
I’ve developed a small script with it and it’s very easy to use but it only handles .NET types.

Hi Yannick,

Thanks for the reply. When you say “only .NET types” what do you mean? I assume that the control can handle booleans, colors, etc? For example, how easy would it be to write and interact with a basic object inspector?

Name
Parent Name
Wirecolor
Properties
Radius
Segments
PRS Controller Type

I’m just using this as an example; this is not my intended usage.

Would you be able / want to post an example?

Many thanks,
Dave

Hi Yannick,

Thanks for the reply. When you say “only .NET types” what do you mean? Can the grid handle booleans, colors, etc? For example, how easy would it be to write and interact with a basic object inspector?

Name
Parent Name
Wirecolor
Properties
Radius
Segments
PRS Controller Type

I’m just using this as an example; this is not my intended usage.

Would you be able / want to post an example?

Hi Dave,

The PropertyGrid can only handle Managed types. According to its name, it only display object properties : methods, events and properties.

Here’s the source code of a scripted utility using a PropertyGrid in order to display the properties of the Environment.Version object :

global Environment = dotNetClass "System.Environment"

utility FrameworkVersionViewer ".NET Version Viewer"
(
	dotNetControl Properties "PropertyGrid" align:#center width:150 height:141
	button btnInformations "View .NET version"
	
	on FrameworkVersionViewer open do
	(
		Properties.HelpVisible = false
		Properties.SelectedObject = Environment.Version
	)
	
	on btnInformations pressed do
	(
		Message  = ".NET Framework installed on your computer is Version "
		Message += Environment.Version.Major    as string + "."
		Message += Environment.Version.Minor    as string + "."
		Message += Environment.Version.Build    as string + "."
		Message += Environment.Version.Revision as string

		MessageBox Message title:".NET Version Viewer"
	)
)

In this example, the most important line is :

Properties.SelectedObject = Environment.Version

So, I think it will be interesting to build a .NET wrapper over some 3ds Max types in order to be able to display them in a PropertyGrid. At that time I’ve no time to develop such wrapper .

OK – I get it. The property grid updates with a 1 to 1 relationship of an object’s properties.

As cool as that is, I’d like to be able to hard-code a series of arbitrary properties, in arbitrary groups of my specification, BUT have it displayed in a user-friendly format, such as a property grid.

If, for example a property on an object changed in max, I would manually update the grid using callbacks. For the application I want, I just need to display and have editable a list of properties that do NOT directly relate to any specific max object.

So, the UI is more important than the interaction. Do you know if there’s any way to do that at present?

Cheers,
Dave

Hi Dave,

With the PropertyGrid from .NET 2.0 Forms it’s not possible to do that. I’ve tried to do the same things as you but the PropertyGrid control just display the properties of a managed object. It’s not possible to change/add/delete properties.

So , I think the best solution is to create a custom user control in .NET. I will take a look at that.

> I think the best solution is to create a custom user control in .NET. I will take a look at that.

Hi again Yannick,
That seems like an exciting investigation! I am also investigating existing .ocx property grids and will let you know what I find out. It doesn’t seem like a big deal does it? Have a user-friendly and familiar UI to interact with… we will see

Thanks for the feedback,
Cheers for now,
Dave

  It should be very easy to hook up a managed object to act as an intermediary between your data and the control. Create a .NET assembly like the following;

 namespace Test
      {
        public class ObjectData
        {
     	  private string name;
     	  private int vertices;
      
     	  public string Name
      	  {
     		 get { return name; }
      		 set { name = value; }
     	  }
      	  public int Vertices
     	  {
     		get { return vertices; }
     		set { vertices = value; }
     	  }
        }
      }
      

Then use the properties (or methods that are then used to set multiple at once) to carry your custom data into a managed object and hook it up in a script like;


   global TestRollout
   global x = dotNet.loadAssembly "C:\\YourObjectData.dll"
   global od = dotNetObject "Test.ObjectData"
   
   rollout TestRollout "Test Panel"
   (
      dotNetControl propGrid "PropertyGrid" align:#center width:200 height:400
      pickbutton picker "Select Object" width:200 
   
      on TestRollout open do
      (
   	  propGrid.HelpVisible = false
   	  propGrid.SelectedObject = od
      )
      on picker picked obj do
      ( 
   	  if obj != undefined do
   	  (
   			od.Name = obj.name
   			---etc.
   			propGrid.SelectedObject = od
   	  )
      )
   )
   createDialog TestRollout width:300 height:500 modal:false
   

You probably won’t even need VS2005 and can get away with using csc.exe (the C# compiler provided with the .NET installation). Just a simple way to create a custom property bag for your properties and then carry them over as a managed object for the .NET property grid control itself. For categories in the property grid you’ll have to apply the correct attributes to the properties in the code of intermediate property bag DLL.

Hi Stefan,

Thanks for the reply by Dave does not want to create a new managed object : he want to add properties to the PropertyGrid on the fly during the execution.

That’s not what I would call “hard-code a series of arbitrary properties”. Though if the actual properties are not known until runtime I’d say a minor class factory pattern would apply to get the job done.

Page 1 / 2