Home > DeveloperSection > Forums > Detecting some text has been selected in a textbox
Dematagoda kamal
Dematagoda kamal

Total Post:2

Points:14
Posted on    February-11-2013 6:23 AM

 C# C# 
Ratings:


 1 Reply(s)
 896  View(s)
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.



AVADHESH PATEL

Total Post:604

Points:4228
Posted on    February-11-2013 6:53 AM

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; 
 } 
 }

Don't want to miss updates? Please click the below button!

Follow MindStick