Copy from thread

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

    Posted 18 Aug 2017 Link to this post

    Simple code

    new System.Threading.Thread(delegate ()
    {               
       
      var grid = new RadGridView();
      grid.Columns.Add("column");
      grid.Rows.Add(new Object[] { "value1" });
      grid.Dock = System.Windows.Forms.DockStyle.Fill;
     
      var form = new RadForm();
      form.Controls.Add(grid);
      form.ShowDialog();
     
    }).Start();

     

    When i try right click + copy on cell i got error:

    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.
  2. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3532 posts

    Posted 21 Aug 2017 Link to this post

    Hello Dominik, 

    Thank you for writing.  

    Note that all UI controls are not thread safe controls in the whole Windows Forms platform (not just Telerik controls, but all controls out there). Here is an article on MSDN, describing how to make thread-safe Winforms UI application. This means that any control from the Telerik UI for WinForms suite is not thread safe as well and cannot be used outside the main UI thread. 

    Please refer to the following forum thread which is quite useful on this topic: http://www.telerik.com/forums/copy-to-clipboard-(different-thread) 
     
    I hope this information helps. Should you have further questions I would be glad to help.

    Regards,
    Dess
    Progress Telerik
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top