How can I display two labels for one node?

How can I display two labels for one node?
I have a scema with icons of devices. Every device has a label for edit the name. I want to display another data (IP Address) about the device. Maybe above the icon.
_____________
|10.161.51.180| - Top label for IP
_________
| |
------> | Icon | ----->
|________|

        _______
        |<u>Device 2</u>| - Bottom label for Name

Now I use the base Initialize of GoIconingNode and I override the function
“CreateLabel”:

protected override GoText CreateLabel(String name)
{
GoText l = null;

        if (name != null)
        {
            l = new DeviceNodeLabel();
            l.Text = name;
            l.Selectable = false;
            l.Alignment = MiddleTop;
            l.AddObserver(this);  
        }
        if (DeviceType != EDeviceType.Network)
        {
            l.Editable = true;
            Editable = true;
        }
        return l;
    }

(I have also a derived class that inherits “goText” class and “createLabel” uses it:
public class DeviceNodeLabel : GoText
{
public DeviceNodeLabel() { }

    // Handle any user edits to ensure uniqueness
    public override String ComputeEdit(String oldtext, String newtext)
    {
        DeviceNode n = this.Parent as DeviceNode;
        if (n != null && n.Document != null)
        {
            return n.MakeUniqueName(newtext);
        }
        return newtext;
    }


    public override void DoBeginEdit(GoView view)
    {
        if ((this.Editor != null))
        {
            return;
        }

        base.DoBeginEdit(view);

        TextBox ctrl = (TextBox)this.Editor.GetControl(view);

        if ((ctrl != null))
        {
            ctrl.MaxLength = 30;
        }
    } 

}

)

You’d have to create a constructor that creates an extra GoText and .Add it to the node. Then, override LayoutChildren to place the second label relative to the icon.



I’m having some hardware problems with my laptop, but I can provide more help when I get into the office on Monday.

Thank you very much for the reply!
Where I have to add the c-tor? in the class “DeviceNodeLabel”? or class “GoIconicNode”?
And what should I do with “Create Label”? It returns only one GoText.

Well, not the c-tor. GoIconicNode uses Initialize to set up the node parts, so, continuing that pattern:

[code]
using System;
using System.Drawing;
using Northwoods.Go;
namespace Node_Link_Demo
{
// This is just a regular GoIconicNode, except that it supports an extra Label
[Serializable]
public class IconicNodeTwoLabels : GoIconicNode
{
public virtual void Initialize(System.Windows.Forms.ImageList imglist, int imgindex, string name, string label2)
{
Initialize(imglist, imgindex, name);
myLabel2.Text = label2;
LayoutChildren(null);
}
public virtual void Initialize(System.Resources.ResourceManager res, string iconname, string name, string label2)
{
Initialize(res, iconname, name);
myLabel2.Text = label2;
LayoutChildren(null);
}
public override void Initialize(System.Windows.Forms.ImageList imglist, int imgindex, string name)
{
base.Initialize(imglist, imgindex, name);
myLabel2 = CreateLabel2("label 2");
this.Add(myLabel2);
}
public override void Initialize(System.Resources.ResourceManager res, string iconname, string name)
{
base.Initialize(res, iconname, name);
myLabel2 = CreateLabel2("label 2");
this.Add(myLabel2);
}
public GoText Label2
{
get { return myLabel2; }
}
public virtual GoText CreateLabel2(string label)
{
return this.CreateLabel(label); // same attributes as main label by default
}

public override void LayoutChildren(GoObject childchanged)
{
base.LayoutChildren(childchanged);
if (this.Initializing) return;
GoObject icon = this.Icon;
if (icon == null) return;

GoText label2 = this.Label2;
if (label2 == null) return;
label2.SetSpotLocation(MiddleBottom, icon, MiddleTop);
}
protected override void CopyChildren(GoGroup newgroup, GoCopyDictionary env)
{
base.CopyChildren(newgroup, env);
IconicNodeTwoLabels newnode = (IconicNodeTwoLabels)newgroup;
newnode.myLabel2 = (GoText)env[myLabel2];
}
private GoText myLabel2 = null;
}
}
[/code]

when created with this code:

IconicNodeTwoLabels iconlabel2 = new IconicNodeTwoLabels();
iconlabel2.Initialize(null, "star.gif", "Device 2", "10.161.51.180");
iconlabel2.Position = new PointF(comment.Left + 500, comment.Bottom + 20);
doc.Add(iconlabel2);
looks like this:

thank you very much!!!
thanks for the effort and help.
it works perfectly and looks very nice!