Hello, me again

I try to make my own propertyGrid about all the element in my Goview (node, link …)

It looks like this :

So I just want the type of the figure (Rectangle, Decision…) and the label inside the figure.

This is a part of my code :

public partial class Propriétés : Form
private GoView myView;
private AppSetting def = new AppSetting();

    public Propriétés()
        this.StartPosition = FormStartPosition.CenterScreen;
    public Object Object
        get { return this.PropertyGrid.SelectedObject; }
            if (this.PropertyGrid.SelectedObject == def) return;
            this.PropertyGrid.SelectedObject = def;

    public GoView View
        get { return myView; }
            this.Object = null;
            myView = value;

    public PropertyGrid PropertyGrid
        get { return propertyGrid1; }

How can I take just the property I need of the nodes I created??

Look at what Flowgrammer does with PropertyGrid, node.UserObject and the Info class. I think that’s a model you can extend to meet your needs.

Flowgrammer it’s an example in the samples of GoDiagramExpress?

In some examples for the propertyGrid, there is a method NodeInfo of type GraphNodeInfo, but where do you find GraphNodeInfo ?

FlowGrammer is only in the full kit, not Express.

GraphNodeInfo is OrgCharter.GraphNode. (and ProtoApp too). Both samples are in Express.

The source code in OrgCharter et ProtoApp for the properties is really complicated…

That’s why we write it for you.

It’s just ;)

I have just some difficulties to use it :s

I’ve got 2 errors in my code :

Inconsistent accessibility: the type of parameter ’ DiagramTiphaine. NewNode ’ is less accessible(approachable) than the method ’ DiagramTiphaine. GraphNodeInfo. GraphNodeInfo (DiagramTiphaine. NewNode) ’

Inconsistent Accessibility: the type of property ’ DiagramTiphaine. NewNode ’ is less accessible(approachable) than the property ’ DiagramTiphaine. GraphNodeInfo. NewNode ’

My code is : using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.IO;
using Northwoods.Go;
using Northwoods.Go.Xml;

namespace DiagramTiphaine
class NewNode : GoBasicNode
public NewNode()
//Création de l’élément graphique

        this.LabelSpot = GoObject.Middle;
        this.Shape.FillShapeHighlight(Color.FromArgb(80, 180, 240), Color.FromArgb(255, 255, 255));
        this.Editable = true;
        this.Text = "Tache";
        this.Label.Editable = true;
        this.Label.Multiline = true;
        this.Port.IsValidDuplicateLinks = true;
        this.Port.IsValidSelfNode = false;
        //return this;

    public override GoObject CopyObject(GoCopyDictionary env)
        NewNode newobj = (NewNode)base.CopyObject(env);
        if (newobj != null)
            newobj.UserObject = new GraphNodeInfo(newobj);
        return newobj;

    //L'élément graphique est de type Rectangle
    protected override GoShape CreateShape(GoPort p)
        return new GoDrawing(GoFigure.Rectangle);

    protected override GoPort CreatePort()
        OneInOneOutBasicPort p = new OneInOneOutBasicPort();
        p.FromSpot = GoObject.NoSpot;
        p.ToSpot = GoObject.NoSpot;
        return p;

public class GraphNodeInfo : ICustomTypeDescriptor
    public GraphNodeInfo(NewNode n) { this.NewNode = n; }

    public NewNode NewNode
        get { return myNode; }
        set { myNode = value; }

    public override String ToString()
        return this.Name;

    // ICustomTypeDescriptor
    /// <summary>
    /// When the document is read-only, this implementation of GetAttributes
    /// dynamically adds a ReadOnlyAttribute to the collection of attributes for
    /// this class, to disable the PropertyGrid in which this object is being
    /// displayed.
    /// </summary>
    /// <returns></returns>
    public AttributeCollection GetAttributes()
        AttributeCollection coll = TypeDescriptor.GetAttributes(this, true);
        ManageDocument doc = this.NewNode.Document as ManageDocument;
        if (doc != null && doc.IsReadOnly)
            ReadOnlyAttribute ro = new ReadOnlyAttribute(true);
            Attribute[] atts = new Attribute[coll.Count + 1];
            coll.CopyTo(atts, 0);
            atts[coll.Count] = ro;
            return new AttributeCollection(atts);
        return coll;

    public String GetClassName() { return TypeDescriptor.GetClassName(this, true); }
    public String GetComponentName() { return TypeDescriptor.GetComponentName(this, true); }
    public TypeConverter GetConverter() { return TypeDescriptor.GetConverter(this, true); }
    public EventDescriptor GetDefaultEvent() { return TypeDescriptor.GetDefaultEvent(this, true); }
    public PropertyDescriptor GetDefaultProperty() { return TypeDescriptor.GetDefaultProperty(this, true); }
    public Object GetEditor(Type editorBaseType) { return TypeDescriptor.GetEditor(this, editorBaseType, true); }
    public EventDescriptorCollection GetEvents() { return TypeDescriptor.GetEvents(this, true); }
    public EventDescriptorCollection GetEvents(Attribute[] attributes) { return TypeDescriptor.GetEvents(this, attributes, true); }
    public PropertyDescriptorCollection GetProperties() { return TypeDescriptor.GetProperties(this, true); }
    public PropertyDescriptorCollection GetProperties(Attribute[] attributes) { return TypeDescriptor.GetProperties(this, attributes, true); }
    public Object GetPropertyOwner(PropertyDescriptor pd) { return this; }

    // Various user visible properties

    [Description("The node's text label")]
    public String Name
        get { return this.NewNode.Text; }
        set { this.NewNode.Text = value; }

    [Description("The name of the document that this node is in")]
    public String Document
        get { return this.NewNode.Document.Name; }
        set { this.NewNode.Document.Name = value; }

    private NewNode myNode = null;


I don’t know why: GraphNodeInfo(NewNode n) and public NewNode NewNode {} are underline ??

You need “public class” on everything. NewNode isn’t.

(and you need NewNode to be [Serializable] too, for other reasons)

Thank you Big%20smile

I took the source code of OrgCharter for my propertyGrid.

I haven’t got errors when I replace some code by mine, but when I run the application nothing displays in the Form.

I look in my code to see where the problem is, but I don’t know…

Moreover it’s complicated for you without all the program to see the problem.

How can I do to resolve this?

Look at SetPropertiesView and how / where it gets called.

I try to see the problem with the debug but nothing.

The method SetPropertiesView: I don’t see any error…

My form about the properties displays but nothing inside. Like if my propertygrid isn’t recognize.

I should have looked closer… SetPropertiesView is only a small part of it. Did you copy all of GraphNodeForm.cs ?

GraphNodeForm watches for DocumentChanged and ObjectGotSelection / ObjectLostSelection events. Setting the GraphNodeForm.View is a critical piece of that (which OrgCharter does in MainForm.ShowProperties).