Click here to Skip to main content
15,949,686 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi everyone!

I have a bit of a scenario, which I’m finding is a wall of my knowledge and experience in terms of winform control development and hoping other developers may share their knowledge in solving.

My scenario is…

I have a tree view control on a windows form, all populated and working fine, no problems.

I would like the user be the able to double click or pushed an add button and the tree node is added to text box, underlined and as a block of text. (Double click/button is implemented and fine).

Single Click + Delete on the block of text in the text box, would only cause that block to be removed, all other blocks in the textbox would be left alone.

Treeview, buttons, etc. is all fine, it’s just this blasted text box (should it even be a text box, or should I just add labels to some control and handle it that way. seems ugly?)

It is somewhat akin to the outlook to field, but forgetting about the resolving (that would be great, but not needed, as they are being entered from the tree view); it is mainly the adding/deleting to the block of text.

Am I barking up the wrong tree with a textbox?

Keen to hear how other developers have handled a situation like/simular to this and what solutions you have used to implement it.

Thanks in advance.

(PS. mainly a web dev here, if I get some terms mixed up or my knowledge is limited, I apologies upfront).

What I have tried:

What have I tried?

- Added labels to a textbox and then having some logic to handle adding/removal
- Adding labels to a user control (as above, just with a UC not a TB)
- Searching the interwebs, but “winform control like outlook” or “winform control add labels to text” box is not bring up anything close to usable or even close, my foo is broken.
-Praying

Adding the labels isnt the problem, its more so how to handle the interactions or deleting / added in the best way possible.
Posted
Updated 16-May-17 20:29pm

1 solution

A text box is the wrong way: if nothing else, it has no "individual text" formatting, so any underlining has to apply to the whole text, you can't apply it to a portion of it at all.
Have a look at a RichTextBox instead - that has individual text formatting, so underlining the new entry is at least possible.
 
Share this answer
 
Comments
DanielBrownAU 17-May-17 2:29am    
Thanks Griff, that may be the pointer I needed. Will give it a crack and see what falls out of the compiler.

Thanks for the input, much appreciated.

Cheers,

DB
OriginalGriff 17-May-17 2:52am    
You're welcome!
DanielBrownAU 18-May-17 0:23am    
I have flopped over to a RichTextField, all fine and dandy getting the underline happening. Thanks for that.

Any pointers or tips on how to treat the added text as a single object to prevent user manipulation or it? (adding/removing letters or deleting the entire term set).

Thanks again.


-DB

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