c# - Add text before selected text in another textbox -
i'm having issues trying 1 textbox change another.
explanation: there 2 richtextboxes (rich1, rich2). rich1 , rich2 have string in there chosen user (their server name). there buttons on form change selected text in rich1 different colours using this:
private void btndarkblue_click(object sender, eventargs e) { rich1.selectioncolor = color.darkblue; }
what i'd happen when clicks colour button, selected text in rich1 same in rich2 want add text before selected text in rich2, example if selects "nh" out of "funhaus" rich2 equal "fu\colour=12\nhaus"
so in end, rich1 display (with colouring): "funhaus". rich2 display (with no colouring): "fun\colour=12haus" user has decided change word "haus" darkblue. here's code i've tried:
rich2.selectedrtf = rich1.selectedrtf;
i assumed because both equal same text work, seems add rich1's selected text beginning of rich2 formatting.
private void rich1_selectionchanged(object sender, eventargs e) { rich2.selectionlength = rich1.selectionlength; rich2.selectionstart = rich1.selectionstart; } private void button2_click(object sender, eventargs e) { rich2.selectedrtf = @"{\rtf1\ansi{colour=12}" + rich2.selectedrtf; rich1.forecolor = color.blue; }
Comments
Post a Comment