---
title: "Detecting some text has been selected in a textbox"  
description: "Detecting some text has been selected in a textbox"  
author: "Dematagoda kamal"  
published: 2013-02-11  
updated: 2013-02-11  
canonical: https://www.mindstick.com/forum/586/detecting-some-text-has-been-selected-in-a-textbox  
category: "c#"  
tags: ["c#"]  
reading_time: 1 minute  

---

# Detecting some text has been selected in a textbox

Hi MindStickians!

I'm new in C#. I want to get [value](https://www.mindstick.com/articles/23219/an-optimized-description-adds-value-to-experience-and-in-turn-effectively-guest-posting-packages) from clipboard ([copy](https://www.mindstick.com/forum/161993/explain-the-numpy-array-copy-vs-view-with-example) [values](https://www.mindstick.com/forum/327/sum-textbox-values)) and selected [string](https://www.mindstick.com/articles/1527/string-split-in-c-sharp) from [textbox](https://www.mindstick.com/forum/12714/dynamic-textbox-in-gridview) if textbox string are selected.

Please help me!

Thanks in advance.

## Replies

### Reply by AVADHESH PATEL

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; } }


---

Original Source: https://www.mindstick.com/forum/586/detecting-some-text-has-been-selected-in-a-textbox

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
