Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6566035
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T14:10:08+00:00 2026-05-25T14:10:08+00:00

I have added hashtable(ID and Name) as custom property for each item (Node). The

  • 0

I have added hashtable(ID and Name) as custom property for each item (Node).
The user can add and update those properties with respect to each items.
My problem is that while updating the Hash Table value of a particular item, the updated value is assigned to all items (nodes) for example while editing the ID of a node to 2 then each node contains the same id value.
I think the problem is that the Hash Table values are not cloned for that particular item because other properties like int vertexcount are working fine.

How to resolve this problem and how to update the property with respect to that particular item? Thanks in advance..

Here is the code for serialization of properties:

[Serializable]
public class DynamicGroup : Group
{
    #region Class members
    private int clickCount;
    #endregion

    #region Class Initialize/Finalize methods
    /// <summary>
    /// Default constructor.
    /// </summary>
    public DynamicGroup()
    {
    }

    /// <summary>
    /// Initialize a new instance of DynamicGroup.
    /// </summary>
    /// <param name="nodes">The node collection.</param>
    public DynamicGroup(NodeCollection nodes)
        : base(nodes)
    { }
    /// <summary>
    /// Copy constructor.
    /// </summary>
    /// <param name="src"></param>
    public DynamicGroup(DynamicGroup src)
        : base(src)
    {
        this.Properties = src.Properties;
    }

    /// <summary>
    /// Serialization constructor for the MySymbol class.
    /// </summary>
    /// <param name="info">Serialization state information</param>
    /// <param name="context">Streaming context information</param>
    protected DynamicGroup(SerializationInfo info, StreamingContext context)
        : base(info, context)
    {
        // The Serialization constructor is invoked during deserialization or during a drag & drop operation.
        // If the MySymbol type has serializable members, then initialize them with the serialized data 
        // obtained from the SerializationInfo param
        foreach (SerializationEntry entry in info)
        {
            switch (entry.Name)
            {
                case "properties":
                    properties = (Hashtable)entry.Value;
                    break;
                case "clickCount":
                    clickCount = (int)entry.Value;
                    break;
            }
        }
    }
    #endregion

    #region Class properties
    /// <summary>
    /// Get or set the dynamic properties collection.
    /// </summary>
    private Hashtable properties = null;
    [Browsable(true), ReadOnly(false)]
    public Hashtable Properties
    {
        get
        {
            if (properties == null)
            {
                properties = new Hashtable();                    
            }
            return properties;
        }
        set
        {
            properties = value;
        }
    }
    [Browsable(true)]
    public int ClickCount
    {
        get
        {
            return clickCount;
        }
        set
        {
            clickCount = value;
        }
    }

    #endregion

    [EventHandlerPriority(true)]
    protected override void OnMouseClick(EventArgs e)
    {
        clickCount = clickCount + 1;
    }

    #region Class overrides
    /// <summary>
    /// Creates a new object that is a copy of the current instance.
    /// </summary>
    /// <returns>Copy of the object this method is invoked against</returns>
    public override object Clone()
    {
        return new DynamicGroup(this);
    }
    /// <summary>
    /// Populates a SerializationInfo with the data needed to serialize the target object.
    /// </summary>
    /// <param name="info">SerializationInfo object to populate.</param>
    /// <param name="context">Destination streaming context.</param>
    protected override void GetObjectData(SerializationInfo info, StreamingContext context)
    {
        base.GetObjectData(info, context);
        //Add the serialization entry for dynamic properties collection           
        info.AddValue("properties", this.properties);
        info.AddValue("clickCount", clickCount);

    }
    #endregion
}

Editing properties:
grp is a node:

private void button2_Click(object sender, EventArgs e)
{
    DynamicGroup grp = diagram1.Controller.SelectionList[0] as DynamicGroup;
    listBox1.Items.Add(grp.ClickCount.ToString());
    listBox1.Items.Add(grp.Properties["Name"].ToString());
    textBox1.Text = grp.Properties["ID"].ToString();
}   

private void textBox1_TextChanged(object sender, EventArgs e)
{
    DynamicGroup grp = diagram1.Controller.SelectionList[0] as DynamicGroup;
    grp.Properties["ID"] = textBox1.Text;
}

The issue is raised while duplicating that is copying the already existed node and update the property of duplicated node..

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T14:10:08+00:00Added an answer on May 25, 2026 at 2:10 pm

    Try changing your Constructor from

    public DynamicGroup(DynamicGroup src): base(src)
    {
        this.Properties = src.Properties;
    }
    

    to

    public DynamicGroup(DynamicGroup src): base(src)
    {
        this.Properties = (Hashtable)src.Properties.Clone();
    }
    

    Otherwise the safe Hashtable will be referenced by both objects, the original and the “clone”.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have added multiple app.config (each with a differet name) files to a project,
I have added multi-language using the short article below. When you add for example
I have added a custom action to the CustomList type. For testing purposes I
I have added a RadControl, RadGrid and I need to add a radComboBox in
If I'm using a Hashtable , I can write code like this: object item
I have added a menu item in ECB of document of document library. On
Have I correctly added an element to a hashTable? Flows flows = new Flows(sIP,dIP);
I have added some code which compiles cleanly and have just received this Windows
I have added the required assemblies and registered the NVelocityViewFactory in global.asax.cs page but
I have added some dynamic textboxes upon a button click. I need the values

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.