Is there a way to add a 2nd text label on a GoIconicNode? I need one label above and one below.
Sure… but I don’t see a single sample that I can point you to. Let me go write one.
Try this:
[Serializable]
public class GoIconicNodeTwoLabel : GoIconicNode
{
public override void Initialize(ImageList imglist, int imgindex, string name)
{
<span =“Apple-tab-span” style=“white-space:pre”> base.Initialize(imglist, imgindex, name);
addTopLabel();
}
public override void Initialize(ResourceManager res, string iconname, string name)
{
<span =“Apple-tab-span” style=“white-space:pre”> base.Initialize(res, iconname, name);
addTopLabel();
}
private void addTopLabel() {
myTopLabel = CreateLabel("top");
this.Add(myTopLabel);
}
public override void LayoutChildren(GoObject childchanged) {
base.LayoutChildren(childchanged);
if (this.Initializing) return;
GoObject icon = this.Icon;
if (icon == null) return;
GoText toplabel = this.TopLabel;
if (toplabel != null) {
toplabel.SetSpotLocation(MiddleBottom, icon, MiddleTop);
}
}
/// <summary>
/// Make copy of the toplabel
/// </summary>
protected override void CopyChildren(GoGroup newgroup, GoCopyDictionary env) {
base.CopyChildren(newgroup, env);
GoIconicNodeTwoLabel newobj = (GoIconicNodeTwoLabel)newgroup;
newobj.myTopLabel = (GoText)env[myTopLabel];
}
public virtual GoText TopLabel {
get { return myTopLabel; }
set {
GoText old = myTopLabel;
if (old != value) {
if (old != null)
Remove(old);
myTopLabel = value;
if (value != null)
Add(value);
Changed(ChangedTopLabel, 0, old, NullRect, 0, value, NullRect);
}
}
}
public virtual String TopText {
get {
GoText lab = this.TopLabel;
if (lab != null)
return lab.Text;
else
return "";
}
set {
GoText lab = this.TopLabel;
if (lab != null)
lab.Text = value;
}
}
public const int ChangedTopLabel = LastChangedHint + 1;
private GoText myTopLabel;
}
Thanks Jake. I will give it a try.
Works perfectly! Thanks!