Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C# (http://www.go4expert.com/forums/c-sharp/)
-   -   Case Flipping (http://www.go4expert.com/forums/case-flipping-t3890/)

x64 16Apr2007 09:51

Case Flipping
 
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 16Apr2007 13:35

Re: Case Flipping
 
You are just changing the selected text but if nothing is selected its made not to work.

x64 17Apr2007 03:27

Re: Case Flipping
 
Oh sorry, I forgot to add that I do have something selected.

shabbir 17Apr2007 06:00

Re: Case Flipping
 
Try something like this
Code:

rtb.SelectedText = rtb.SelectedText.ToLower();
and see if it works.

x64 17Apr2007 06:53

Re: Case Flipping
 
Nice! It does work thanks a ton. I can't believe that I didn't think of that myself, it's so simple.

shabbir 17Apr2007 08:25

Re: Case Flipping
 
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.

:D


All times are GMT +5.5. The time now is 03:46.