VB.NET Multiline Textbox
-
I have a multiline text box on a form in a windows application.If some portion of teh text appears inside a tag like this ,#some text#.Then I want to make that portion of the text non editable.Can i implement this.How do i go about this.Later I want to replace the text between the pound symbol with data from a database while printing a report.So I don't want the user to edit the text inside the tag.These tags will be inserted from a list of values.The user should be able to edit the remaining part of the text box.These tags can come anywhere inside the text box and more than once.
-
I have a multiline text box on a form in a windows application.If some portion of teh text appears inside a tag like this ,#some text#.Then I want to make that portion of the text non editable.Can i implement this.How do i go about this.Later I want to replace the text between the pound symbol with data from a database while printing a report.So I don't want the user to edit the text inside the tag.These tags will be inserted from a list of values.The user should be able to edit the remaining part of the text box.These tags can come anywhere inside the text box and more than once.
Though it is probably not the best way to do it, this is probably what I would do: I would set the form's KeyPreview Property to true, making the form's KeyUp, KeyPress, and KeyDown Events (and whatever sub(s) you may have to handle them) get a crack at what the user pressed before the textbox would. If you did this, then you would then write some algorithm to determine whether the character that the user pressed (if it was entered at the cursor or in place of any selected text) would cause one of your tags to change. If it would, then you absorb the keystroke by setting the KeyPressEvents.Handled Property of "e" and then do nothing else. If I'm right, and of course if you can figure out that algorithm, then the effect should be an un-alterable "tag" in the middle (or any other part) of the text box control I do wonder: What if someone accidentally inserts an incorrect tag (like #dog# where it should be #one if by land, two if by sea#)"? Do you have an erase function? If you do have that algorithm working, maybe you could use part of it to select tags when you double click (or even single click) on the text box; then have a button to delete the tag. As for a mostly different approach, you could have buttons (or whatever) to insert the tags, and let the users edit them to their heart's content. However, when the user submits the text for processing, have an algorithm go through and correct simple mistakes in the tags and/or point out invalid tags, giving the user a chance to cancel their submission, or change the tags at that time ("Spell-Check" Style - but with tags) Oh Yeah - Good Luck P.S.: Feel free to mention me in the about box if you feel my contribution was valuable - and, uh... any checks in the mail would be welcome too :laugh:
sincerely, Brett Peirce - PolerBear To err is human; To forgive: divine.
-
Though it is probably not the best way to do it, this is probably what I would do: I would set the form's KeyPreview Property to true, making the form's KeyUp, KeyPress, and KeyDown Events (and whatever sub(s) you may have to handle them) get a crack at what the user pressed before the textbox would. If you did this, then you would then write some algorithm to determine whether the character that the user pressed (if it was entered at the cursor or in place of any selected text) would cause one of your tags to change. If it would, then you absorb the keystroke by setting the KeyPressEvents.Handled Property of "e" and then do nothing else. If I'm right, and of course if you can figure out that algorithm, then the effect should be an un-alterable "tag" in the middle (or any other part) of the text box control I do wonder: What if someone accidentally inserts an incorrect tag (like #dog# where it should be #one if by land, two if by sea#)"? Do you have an erase function? If you do have that algorithm working, maybe you could use part of it to select tags when you double click (or even single click) on the text box; then have a button to delete the tag. As for a mostly different approach, you could have buttons (or whatever) to insert the tags, and let the users edit them to their heart's content. However, when the user submits the text for processing, have an algorithm go through and correct simple mistakes in the tags and/or point out invalid tags, giving the user a chance to cancel their submission, or change the tags at that time ("Spell-Check" Style - but with tags) Oh Yeah - Good Luck P.S.: Feel free to mention me in the about box if you feel my contribution was valuable - and, uh... any checks in the mail would be welcome too :laugh:
sincerely, Brett Peirce - PolerBear To err is human; To forgive: divine.