Copy to clipboard (different thread)

2 posts, 0 answers
  1. Dominik
    Dominik avatar
    82 posts
    Member since:
    Dec 2012

    Posted 28 Oct 2015 Link to this post


    I open the window containing RadGridView as follows:

    new System.Threading.Thread(delegate () {

      FormReports FormReports = new FormReports();

    When trying to copy data from the grid (right click -> copy) error message pops up:

    An unhandled exception of type 'System.Threading.ThreadStateException' occurred in System.Windows.Forms.dll
    Additional information: Current thread must be set to single thread apartment (STA) mode before OLE calls can be made. Ensure that your Main function has STAThreadAttribute marked on it.

    In this case I can't avoid new thread when calling new form.

    How to solve it?​


    new System.Threading.Thread(delegate () { 
      FormReports FormReports = new FormReports();
  2. Dess | Tech Support Engineer, Sr.
    Dess | Tech Support Engineer, Sr.  avatar
    4166 posts

    Posted 28 Oct 2015 Link to this post

    Hello Dominik,

    Thank you for writing.

    It does not seem to be an issue RadGridView. When you copy data from grid, we use Clipboard.SetDataObject method. If it is called from another thread, the mentioned exception occurs. This problem can be reproduced with the default WinForms controls as well without using any Telerik component: 
    public partial class Form1 : Form
        public Form1()
            new System.Threading.Thread(delegate()
                Form f = new Form();
                Button b = new Button();
                b.Click += b_Click;
        private void b_Click(object sender, EventArgs e)

    You can find additional information on this topic on the following links:

    I hope this information helps. Should you have further questions I would be glad to help.
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top