# Property panel with c#

**URL:** <https://discourse.mcneel.com/t/property-panel-with-c/166>\
**Category:** Rhino Developer\
**Created:** [June 13, 2013, 3:03pm UTC](https://discourse.mcneel.com/t/property-panel-with-c/166 "2013-06-13T15:03:54Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![gerryark](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/gerryark/32/634941_2.png) [@gerryark](https://discourse.mcneel.com/u/gerryark)\
**Post date:** [June 13, 2013, 3:03pm UTC](https://discourse.mcneel.com/t/property-panel-with-c/166/1 "2013-06-13T15:03:54Z")

</div>

Hi to all

Well I am going to update a plugin written in c++ but I want to split it in 2 parts

1. All the heavy math stuff inside a c++ 64 bit plugin
2. interface stuff in a c# plugin

Since I am a newbie in c# and have no idea on where to start to add a Property panel in rhinoui  
does anybody have a code snippet of a property panel to share ?

or at least point me on how to create one ?  
I have searched for the code examples in the rhinocommon but nothing related to UI and interfaces

gerry

---

<div class="post-metadata">

**Author:** ![dale](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/dale/32/685184_2.png) [@dale](https://discourse.mcneel.com/u/dale)\
**Post date:** [June 13, 2013, 3:26pm UTC](https://discourse.mcneel.com/t/property-panel-with-c/166/2 "2013-06-13T15:26:20Z")

</div>

Hi Gerry,

If you are looking to create a docking panel, see the following examples:

> **[mcneel/rhinocommon](https://github.com/mcneel/rhinocommon/tree/master/examples/PanelSamplePlugIn)**
>
> RhinoCommon is the .NET SDK for Rhino5 / Grasshopper - mcneel/rhinocommon

  
[https://github.com/dalefugier/SampleCsPanel](https://github.com/dalefugier/SampleCsPanel)

If you are looking for something else, let me know.

– Dale

---

<div class="post-metadata">

**Author:** ![TomC](https://avatars.discourse-cdn.com/v4/letter/t/8dc957/32.png) [@TomC](https://discourse.mcneel.com/u/TomC)\
**Post date:** [June 13, 2013, 9:35pm UTC](https://discourse.mcneel.com/t/property-panel-with-c/166/3 "2013-06-13T21:35:06Z")

</div>

If you are new to c# and looking for the actual control for a “property panel” style control (assuming you are using WinForms) you’ll want to check out the PropertyGrid in the Controls ToolBox when you are making your form (it may not show up under the Common Controls section, but shows up under All Windows Forms). I’m quite fond of them, and have used them in my own Rhino Docking Panels. You end up writing a lot of wrapper “Properties”, but for me it’s less overhead and headache than having to code 30 edit boxes…

HTH,  
tom

---

<div class="post-metadata">

**Author:** ![gerryark](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/gerryark/32/634941_2.png) [@gerryark](https://discourse.mcneel.com/u/gerryark)\
**Post date:** [June 14, 2013, 9:56am UTC](https://discourse.mcneel.com/t/property-panel-with-c/166/4 "2013-06-14T09:56:14Z")

</div>

Dale & Tom

This is what I was searching for

Thanks a lot

gerry

---

<div class="post-metadata">

**Author:** ![jonm](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/jonm/32/502039_2.png) [@jonm](https://discourse.mcneel.com/u/jonm)\
**Post date:** [June 22, 2015, 11:07pm UTC](https://discourse.mcneel.com/t/property-panel-with-c/166/5 "2015-06-22T23:07:56Z")

</div>

Hi All,

Thanks in advance for any help. I’ve been looking with no success about how to develop a panel with a “dynamic” update based on user selection in Rhino.

At present the data is stored as usertext, and I’d like to be able to “disable” the displayed value if it differs when multiple objects are selected. Something like the display color. If the sample also showed a pick list like this, it would be great.

 ![](https://global.discourse-cdn.com/mcneel/uploads/default/original/3X/9/4/94a3da346b3ea27531c75cc48c5eb7c0c42bfa2e.png) 

Thanks again

Jon

---

<div class="post-metadata">

**Author:** ![dale](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/dale/32/685184_2.png) [@dale](https://discourse.mcneel.com/u/dale)\
**Post date:** [June 24, 2015, 8:21pm UTC](https://discourse.mcneel.com/t/property-panel-with-c/166/6 "2015-06-24T20:21:33Z")

</div>

Hi Jon,

If I understand correctly, you want to enable or disable items on the Properties page (panel) depending on what is selected. This is not possible using any Rhino SDK.

You can, though, add custom pages to the Properties panel. The Material, Texture Mapping, and Detail pages (shown in your image) are examples of this.

Does this answer your question?

---

<div class="post-metadata">

**Author:** ![jonm](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/jonm/32/502039_2.png) [@jonm](https://discourse.mcneel.com/u/jonm)\
**Post date:** [June 24, 2015, 10:21pm UTC](https://discourse.mcneel.com/t/property-panel-with-c/166/7 "2015-06-24T22:21:03Z")

</div>

Hi Dale,

Hope you’re well.

Yes, adding custom pages to the properties panel sounds like what I would like.  
Are there any samples (or pointers) demonstrating this?

Thanks,

Jon

---

<div class="post-metadata">

**Author:** ![jonm](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/jonm/32/502039_2.png) [@jonm](https://discourse.mcneel.com/u/jonm)\
**Post date:** [June 27, 2015, 12:21am UTC](https://discourse.mcneel.com/t/property-panel-with-c/166/8 "2015-06-27T00:21:34Z")

</div>

I’m assuming this is relevant?

> **[Custom properties window](http://discourse.mcneel.com/t/custom-properties-window/11106)**
>
> Hi, Is it possible to customize properties tab? I need to display user strings whenever I select the object.

Is this working in Rhino WIP? I also assume this isn’t available in dotnet for v5.

Thanks,

Jon

---

<div class="post-metadata">

**Author:** ![dale](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/dale/32/685184_2.png) [@dale](https://discourse.mcneel.com/u/dale)\
**Post date:** [July 1, 2015, 5:30pm UTC](https://discourse.mcneel.com/t/property-panel-with-c/166/9 "2015-07-01T17:30:49Z")

</div>

Hi Jon,

Sorry for the delay - here is a simple example.

[https://github.com/dalefugier/SampleCsObjectProperties](https://github.com/dalefugier/SampleCsObjectProperties)

Let me know if you have questions.

---

<div class="post-metadata">

**Author:** ![jonm](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/jonm/32/502039_2.png) [@jonm](https://discourse.mcneel.com/u/jonm)\
**Post date:** [July 8, 2015, 10:34pm UTC](https://discourse.mcneel.com/t/property-panel-with-c/166/10 "2015-07-08T22:34:30Z")

</div>

Hi Dale,

This is great (sorry, I didn’t spot the reply earlier and if I got a notification I didn’t recognize it).

I’ll take a look further at implementing this.  
Now I just need to think the logistics of how to support this as I’m assuming many of my users are still on RC0 of v5.

I’ll be back if I have further questions.

Cheers,

Jon

---

<div class="post-metadata">

**Author:** ![jonm](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/jonm/32/502039_2.png) [@jonm](https://discourse.mcneel.com/u/jonm)\
**Post date:** [July 8, 2015, 11:23pm UTC](https://discourse.mcneel.com/t/property-panel-with-c/166/11 "2015-07-08T23:23:45Z")

</div>

For anyone looking to still build against an older rhcommon dll but support this, I found using reflection I could invoke the SelectedObjects property using this code in the SampleCsObjectPropertiesPage class

RhinoObject[] robjs = this.GetType().GetProperty(“SelectedObjects”).GetValue(this, null) as RhinoObject[];  
foreach (RhinoObject rh\_obj in robjs)

---

<div class="post-metadata">

**Author:** ![dale](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/dale/32/685184_2.png) [@dale](https://discourse.mcneel.com/u/dale)\
**Post date:** [July 8, 2015, 11:59pm UTC](https://discourse.mcneel.com/t/property-panel-with-c/166/12 "2015-07-08T23:59:48Z")

</div>

> [@jonm](#):
>
> Now I just need to think the logistics of how to support this as I’m assuming many of my users are still on RC0 of v5.

If your plug-in references Rhino 5 SRx, then your customers will be required to be using Rhino 5 SRx or greater to use your plug-in.

Building against the latest Rhino SR is a good way to make sure your customers are up-to-date.

Does this help?

---

<div class="post-metadata">

**Author:** ![jonm](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/jonm/32/502039_2.png) [@jonm](https://discourse.mcneel.com/u/jonm)\
**Post date:** [July 9, 2015, 12:09am UTC](https://discourse.mcneel.com/t/property-panel-with-c/166/13 "2015-07-09T00:09:01Z")

</div>

Hi Dale,

Thanks for the reply. In an ideal world, yes I would only build against latest release. But I have some clients who never move from SR0. Not necessarily the end users, but typically the IT support in charge of deployments (usually in large firms). Users don’t have admin permissions on their computer. Whilst it should be obvious that fixes and improvements are there to be gained, it’s not as easy as observing that. So if I try to enforce latest build I’m going to loose clients and users. I actually only recently stopped supporting v4.0 (although I was enforcing a service release on this, v4SR0 was too many years ago).

This isn’t necessarily a problem for me, this is the first time where I’ve found a property in a new release that I really wanted to use. Especially given that it seems it’s only one property, Using reflection I’ll be able to disable the panel on incompatible installations, and support the feature in those that do.

Far from ideal, but it’s a real situation.

Appreciate your help and support a lot,

Jon

---

<div class="post-metadata">

**Author:** ![jeffoulet](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/jeffoulet/32/499869_2.png) [@jeffoulet](https://discourse.mcneel.com/u/jeffoulet)\
**Post date:** [November 9, 2016, 4:48pm UTC](https://discourse.mcneel.com/t/property-panel-with-c/166/14 "2016-11-09T16:48:14Z")

</div>

Hi Dale,

(I hope I’m at the right place for my question :] )

In your helpfull plugin sample “SampleCsObjectProperties” you’re displaying the radius of a circle in an custom property panel.

Would it be for example possible, as the panel close (i.e. when the object is deselected), to store the displayed radius as the object name itself?

The final goal would to be able to display/modify custom objects UserText’s from a custom Panel. I’m quite a newbie in C# programming, I already (& roughly) achieved to display a UserText value, but I don’t get how to update it as the panel close.

> ```
> public override void InitializeControls(RhinoObject rhObj)
> {
> foreach (var rh_obj in SelectedObjects)
> {
> if (null != rh_obj)
> {
> if (null != rh_obj.Attributes.GetUserStrings())
> {
> Rhino.RhinoApp.WriteLine(rh_obj.Attributes.GetUserString("SampleUserStrKey").ToString());
> }
> break;
> }
> }
> }
> 
> ```

Many thanks in advance!
