How to paste text from clipboard into a TextBox to 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)
        {
            textBox1.Focus();

            if (Clipboard.GetDataObject().GetDataPresent(DataFormats.Text))
            {
                textBox1.Paste();
            }
        }
    }
}




/*
run:
 

  
*/

 



answered Jan 6, 2024 by avibootz

Related questions

1 answer 125 views
125 views asked Aug 7, 2023 by avibootz
1 answer 148 views
1 answer 123 views
1 answer 168 views
1 answer 134 views
...