Click here to Skip to main content
15,886,110 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
I have a RichTextBox and some Buttons(TEMPLET1,TEMPLET2,TEMPLET3....). When a button is clicked 1st time 2 paragraphs of text is added to the FlowDocument of the RichTextBox.

Below is the screenshot of the application.

ClickHere

My question is, how can i delete a specific template from RichTextBox when i click its respective template button 2nd time.

Any ideas are welcome. It would be great if someone can give a sample code on this.

Thanks in advance.
Posted
Updated 19-Sep-14 0:33am
v3
Comments
Sergey Alexandrovich Kryukov 19-Sep-14 4:16am    
Why? why?!
—SA

1 solution

Well, don't put the button inside this control. Why? Do some nice UI design and find a nice place for this button, such as a toolbar/toolbox. This action is not the only one, so you can allow yourself to put them all together. By the way, this is want most customers will expect, and you should not confuse them too much. And then, what's wrong with traditional menu? Even if you have something else, the comprehensive traditional menu is a must for all more or less complex applications.

—SA
 
Share this answer
 
Comments
Rajput Pavan 19-Sep-14 6:08am    
Thanks for the suggestion, Please check my updated question and help me.
Sergey Alexandrovich Kryukov 19-Sep-14 10:36am    
Do you add each "TEMPLATE" only once? If you add 3, do you want to delete all 3?
In all cases, for each button, store the location of the added text to delete later. On each modification of text, update it accordingly. Use for deletion.

But I don't like the whole idea. Why doing all that?

—SA
Rajput Pavan 20-Sep-14 14:25pm    
I am not sure if this is the best approach to my requirement. If not please suggest one.

My Requirement is:
I have some templates which i want to insert in the RichTextBox on demand. Once user is done with editing the text in the RichTextBox. I will save the text as a document and then user can print or export this document as PDF. But before saving i want to check for an unedited template i.e., a template is added to the RichTextBox but not edited. In this case i want to delete such templates.
Below is a same template:

TEMPLET1
Name:
Age:
Phone Nuumber:

TEMPLET2
Street:
Country:
Pin:

Thanks in advance.
Sergey Alexandrovich Kryukov 20-Sep-14 14:32pm    
Before talking about requirements, please explain your ultimate goal. It's possible (and even likely) that requirements are bad; then you would need to address the problem with the one who gave you these requirements and/or let this person talk to us.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900