We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Clearing of labels from a symbol

Currently my application adds my custom symbol to the diagram from the palette. This symbol contains 2 labels which I added in Symbol Designer. My goal is to add my own labels to the symbol when it has been added to the diagram. Currently I have had no joy so instead am trying to clear the existing labels. When the user clicks a button then the following code is invoked: private void btnAddLabel_Click(object sender, System.EventArgs e) { DiagramForm frm = (DiagramForm)ActiveMdiChild; foreach (Symbol sym in frm.Diagram.Model.Nodes) { foreach (Label lbl in sym.Labels) MessageBox.Show(lbl.Text); sym.Labels.Clear(); } However, the labels are not removed from the screen. When I inspect the Labels property of the Symbol there are no labels. Should I be calling another method to refresh the diagram? I have tried each of the following afterwards but to no avail. frm.Diagram.Refresh(); frm.Diagram.View.Update(): Help appreciated. Jimski

1 Reply

AD Administrator Syncfusion Team September 17, 2004 12:31 PM

Hi Jimski You should use the Symbol''s Remove() or RemoveAt() Method to remove the labels from the symbol. Here is a code snippet which demonstrates how you can remove labels of a custom symbol: MySymbol(s) in a Diagram: //Remove Lables in MySymbol foreach (MySymbol sym in this.diagram1.Model.Nodes) { for (int i=sym.Labels.Count-1; i>=0; i--) { sym.Labels.RemoveAt(i); } } this.diagram1.Refresh(); } Regards Arun

Loader.
Live Chat Icon For mobile
Up arrow icon