0

The main idea is to change the text inside RichTextBox to the chosen Font/Color from the Color&FontDialog, this was simple for selecting the text and then changing the selected portion of the text.

What i want to do is, when there is no text selected, but the fontDialog-Button has been pressed and the desired font is chosen, then the effect will go on all text in the RTF, the same goes to Coloring

Winter
  • 35
  • 9
  • 1
    anything tried yet ? – Felix D. Apr 06 '17 at 06:57
  • You need to __temporarily__ select the whole text and apply the styling. Then de-select. – TaW Apr 06 '17 at 07:03
  • @Felix D.minor things that Logical would work but since im a starter i might have just written them wrong or overall my logic is flawed – Winter Apr 06 '17 at 07:04
  • @TaW That's one way, but i want to do it so where No text is selected and then by pressing the font/colorDialog button it would apply it to all text – Winter Apr 06 '17 at 07:05
  • That is what I wrote. Note the _temporarily_ !! – TaW Apr 06 '17 at 07:06
  • @TaW I dont want to select the Text **at all** it should work through code so if no text selected but the desired font is chosen through fontdialog and then pressed OK all text will be change to that font **without selecting any text** PS: I dont see how this is a duplicate to the presumed post, that post does not answer my question – Winter Apr 06 '17 at 07:13
  • 2
    you can select the text in the code by setting `SelectionStart` and `SelectionLength` property, then unselect it after you have finished assigning the colour. This is what TaW meant – Mong Zhu Apr 06 '17 at 07:16
  • 2
    It is a duplicate because the answer(s) show how you can select Text in code and then style it. To select all write: `.....if (xxxDlg...) {int lastPos = rtb.SelectionStart;rtb.SelectionStart=0;rtb.Selection.Length=rtb.Text.Length; rtb.SelectionFont/Color=...;rtb.SelectionLength=0; rtb.SelectionStart=lastPos;` Note how I deselect all and store/restore the cursor position! – TaW Apr 06 '17 at 07:38
  • Oh my goodness, apologizes for my ignorance, now I understand what you meant. Huge thank you for your patience! – Winter Apr 07 '17 at 14:01

0 Answers0