Case Flipping

x64
Go4Expert Member
16Apr2007,09:51   #1
x64's Avatar
Hello,

I have a richtextbox that I am to be able to type in, I want to be able to select the text and flip the case of the selected string. So... "hello world" would magically be "HELLO WORLD". Here is what I currently have, it does not work, but it does not spit any errors at me. Any ideas?

Code:
   private void lowerCaseToolStripMenuItem_Click(object sender, EventArgs e)
   {
      RichTextBox rtb = (RichTextBox)tabs.SelectedTab.Controls[0]; ;
      rtb.SelectedText.ToLower();
   }
Thanks
Go4Expert Founder
16Apr2007,13:35   #2
shabbir's Avatar
You are just changing the selected text but if nothing is selected its made not to work.
x64
Go4Expert Member
17Apr2007,03:27   #3
x64's Avatar
Oh sorry, I forgot to add that I do have something selected.
Go4Expert Founder
17Apr2007,06:00   #4
shabbir's Avatar
Try something like this
Code:
rtb.SelectedText = rtb.SelectedText.ToLower();
and see if it works.
x64
Go4Expert Member
17Apr2007,06:53   #5
x64's Avatar
Nice! It does work thanks a ton. I can't believe that I didn't think of that myself, it's so simple.
Go4Expert Founder
17Apr2007,08:25   #6
shabbir's Avatar
Quote:
Originally Posted by x64
Nice! It does work thanks a ton. I can't believe that I didn't think of that myself, it's so simple.