Edit text in a textnode
Thanks for using syncfusion products.
|
when I want to edit a text in a textnode I do the following steps:
1. look for the node. 2. Clone it. 3. Delete the original one. 4. Assign the new text. 5. Append the new node into the diagram.
This is the code that I use:
Node existeNode = f_parent.diagram1.Model.GetChildByName(nodeText.Name);
if (existeNode != null) { TextNode tn = ((TextNode)nodeText).Clone() as TextNode; f_parent.diagram1.Model.RemoveChild(((TextNode)nodeText)); tn.Text = "new text"; f_parent.diagram1.Model.AppendChild(tn); }
Is there any way to make it more simple? Without clone and delete the original node? |
Before looking into the requirement could you please provide us what is the actual intention for Cloning the original node and deleting the original node?
Since the requirement can be achieved by removing the existing node and adding the new node instead of cloning the original node.
If we misunderstand your requirement could you please provide us more information about your requirement which will help us to analyze further and provide you a better solution? |
|
Doing that way I have problems when the zoom of the diagram is different of 100% |
Could you please provide us more information probably a video and related files used in your application which reproduces the reported concern will help us to analyze further and provide you a better solution? |
Please let us know if any concerns.
Regards,
Swarnesh K
Attachment: Video_1436778515_34b68200.zip
Thanks for your update.
|
Then I don't need to clone the node? But the name of the new node will be different, won't be? I want to edit the text of the textnode but without losing the node name, is it possible? Could you send me an example? |
We are glad to inform you that we have created a simple sample to achieve your requirement. We suggest you to remove the existing node and create a new node with respect to the existing node so that the old node is removed and new node has been created and same name has been assigned which is to be done in TextEditor_TextChanged event. Please refer the below code snippet and sample for your reference.
Here is the code snippet:
[C#]
diagram2.Controller.TextEditor.TextChanged+=TextEditor_TextChanged;
void TextEditor_TextChanged(object sender, EventArgs e) { //Removing the Existing node. this.diagram2.Model.RemoveChild(((TextNode)existeNode)); //Creation of new node. TextNode Tn2 = ((TextNode)existeNode) as TextNode; //Assigning the existing node’s name to the new node. Tn2.Name = existeNode.Name; }
Here is the Sample:
|
|
And I send you a video with the problem with the zoom.
|
We suggest you to update the TextNode’s font size based on the size of the node. Please refer the below code snippet and video for your reference.
Here is the code snippet:
Tn2.Text = "This is the Text Node This is the Text Node This is the Text Node This is the Text Node This is the Text Node This is the Text Node This is the Text Node This is the Text Node This is the Text Node"; Tn2.SizeToText(new SizeF(Tn2.Text.Length, Tn2.Size.Height)); Tn2.WrapText = true;
Here is the Video:
|
Please let us know if any concerns.
Regards,
Swarnesh K
n2.WrapText = true;
I have tried it but the result it's the same.
Attachment: Video_1436960644_5f686131.zip
Thanks for your update.
We have created a simple sample to achieve your requirement. We suggest you to use TextEditor’s “EndEdit” method and pass the parameter as false in order to achieve your requirement. Please refer the below code snippet and sample for your references.
Here is the code snippet:
[C#]
diagram1.Controller.TextEditor.EndEdit(false);
Here is the video:
Video
Here is the sample:
Sample
Please let us know if any concerns.
Regards,
Naganathan K G
if (tn.FontStyle.Size != 12)
{
tn.FontStyle.Size = 12;
}
But I think the fontsize should remain the same.
Thanks for your patience.
We are able to reproduce the issue reported by you at our end. We have forwarded this to our development team for further analysis. We will update you with our development team’s response in one business day 21st July 2015.
Please let us know if any concerns.
Regards,
Swarnesh K
Thanks for your update.
We are glad to inform you that we have successfully achieved your requirement by modifying the sample. We suggest you to pass “true” in diagram1.Controller.TextEditor.EndEdit’s parameter to avoid changing of font size. We have attached the modified sample, code snippet and video for your reference.
Here is the code snippet:
[C#]
diagram1.Controller.TextEditor.EndEdit(true);
Here is the modified Sample:
Sample
Here is the Video:
Video
Please let us know if any concerns.
Regards,
Swarnesh K
Hi Blanca,
Thanks for your update.
We are glad to inform you that we have successfully achieved your requirement by modifying the sample. We suggest you to pass “true” in diagram1.Controller.TextEditor.EndEdit’s parameter to avoid changing of font size. We have attached the modified sample, code snippet and video for your reference.
Here is the code snippet:
[C#]
diagram1.Controller.TextEditor.EndEdit(true);
Here is the modified Sample:
Sample
Here is the Video:
Video
Please let us know if any concerns.
Regards,
Swarnesh K
Thanks for your update.
We are happy to assist you and please let us know if you need any further assistance.
Regards,
Naganathan K G
- 11 Replies
- 3 Participants
-
BC Blanca Calderon
- Jul 10, 2015 07:08 AM UTC
- Jul 23, 2015 04:36 AM UTC