DETECTING SOME TEXT HAS BEEN SELECTED IN A TEXTBOX

Dematagoda kamal

Total Post:2

Points:14
Posted by  Dematagoda kamal
C# 
C#
 1224  View(s)
Ratings:
Rate this:

Hi MindStickians!

I'm new in C#. I want to get value from clipboard (copy values) and selected string from textbox if textbox string are selected.

Please help me!

Thanks in advance.

  1. AVADHESH PATEL

    Post:604

    Points:4228
    Re: Detecting some text has been selected in a textbox

    Hi Dematagoda!


    Used below line of code

    private void button1_Click(object sender, EventArgs e) 
     { 
     if (textBox1.SelectionLength > 0) 
     { 
     string clipString = System.Windows.Forms.Clipboard.GetText(); 
     string SelString = textBox1.SelectedText; 
     } 
     }

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!