Author Topic: small C# question..  (Read 2412 times)

0 Members and 1 Guest are viewing this topic.

Offline jwalker

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 660
  • Rating: +13/-0
  • Almost everything I have released includes a 'WZ'
    • View Profile
small C# question..
« on: March 10, 2012, 02:09:28 pm »
in vb.net it could be done like this:
Code: [Select]
CType(TabControl1.SelectedTab.Controls.Item(0), RichTextBox).Textthis is to change the text in a rich text box in a certain tab page.
since there is no such function in C#, how would i do this?
<a href="http://www.nerdtests.com/ft_cg.php?im">
<img src="http://www.nerdtests.com/images/ft/cg.php?val=9612" alt="My computer geek score is greater than 41% of all people in the world! How do you compare? Click here to find out!"> </a>

Support Casio-Scene against the attacks of matt @ matpac.co.uk ! For more information: Casio-Scene shuts down & Matt actions threads

Offline BlakPilar

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 734
  • Rating: +44/-1
    • View Profile
Re: small C# question..
« Reply #1 on: March 10, 2012, 02:12:53 pm »
Well, there is a C# function, but it's not actually a function. CType is VB's way of casting. There are two ways you can do what you want to do in C#:
Code: [Select]
RichTextBox rtb = TabControl1.SelectedTab.Controls[0] as RichTextBox;
Then you would access the text by using "rtb.Text". The other way you could do this is by direct casting:
Code: [Select]
((RichTextBox)TabControl1.SelectedTab.Controls[0]).Text
« Last Edit: March 10, 2012, 02:13:24 pm by BlakPilar »

Offline jwalker

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 660
  • Rating: +13/-0
  • Almost everything I have released includes a 'WZ'
    • View Profile
Re: small C# question..
« Reply #2 on: March 10, 2012, 02:15:35 pm »
ohhh, cool i didnt know that.
well it works so thanks.
<a href="http://www.nerdtests.com/ft_cg.php?im">
<img src="http://www.nerdtests.com/images/ft/cg.php?val=9612" alt="My computer geek score is greater than 41% of all people in the world! How do you compare? Click here to find out!"> </a>

Support Casio-Scene against the attacks of matt @ matpac.co.uk ! For more information: Casio-Scene shuts down & Matt actions threads

Offline BlakPilar

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 734
  • Rating: +44/-1
    • View Profile
Re: small C# question..
« Reply #3 on: March 10, 2012, 02:16:28 pm »
No problem :)