Case Flipping

x64's Avatar, Join Date: Apr 2007
x64
Go4Expert Member
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
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
You are just changing the selected text but if nothing is selected its made not to work.
x64's Avatar, Join Date: Apr 2007
x64
Go4Expert Member
Oh sorry, I forgot to add that I do have something selected.
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
Try something like this
Code:
rtb.SelectedText = rtb.SelectedText.ToLower();
and see if it works.
x64's Avatar, Join Date: Apr 2007
x64
Go4Expert Member
Nice! It does work thanks a ton. I can't believe that I didn't think of that myself, it's so simple.
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
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.