Jump to content
Xtreme .Net Talk

Recommended Posts

Posted (edited)

I have a Rich textbox and have some text in it, What im trying to do is when the user selects text and clicks a button it will replace that selected text with something like <tag>{selected text}</tag> How would i do this?

 

 

EDIT--------------------------------------------------------------------

Ok well i got what i wanted after playing around with the code for a while,

 

   Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
       codebox.Copy()
       tmptext.Paste()
       formattext.Text = "<b>" + tmptext.Text + "</b>"
       formattext.Select()
       formattext.Copy()
       codebox.Paste()
       formattext.Clear()
       tmptext.Clear()
   End Sub

 

But if anyone knows a better way, Please do tell me.

Edited by Getox

Page Edit 2.0 Alpha 2 OUT NOW!

- Download Now -

Posted

Oh thats great, theres a heap of code replaced by 1 line of code :)

 

I edited it a bit heres the code:

codebox.SelectedText = "<b>" + codebox.SelectedText + "</b>"

Page Edit 2.0 Alpha 2 OUT NOW!

- Download Now -

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...