How to get the selected text from TextBox using WinForms in C#

1 Answer

0 votes
namespace WinFormsApp1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string selectedText = textBox1.SelectedText;

            MessageBox.Show(selectedText);
        }
    }
}




/*
run:
 

  
*/

 



answered Jan 6, 2024 by avibootz

Related questions

1 answer 179 views
1 answer 148 views
1 answer 123 views
1 answer 133 views
1 answer 133 views
...