Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Datagrid (.Net) exception when i hit CTRL+C

  • 03-08-2004 3:11pm
    #1
    Registered Users, Registered Users 2 Posts: 2,758 ✭✭✭


    Folks,

    Like it says above...

    When i hit Control C in a datagrid on my for i get an exception which boils down to [see attached file].

    It doesn't happen when i hit Ctrl + A/ CTRL + V / CTRL + X etc.

    The grid is bound to a DataView which has its AllowEdit/AllowDelete/AllowNew set to false. Its the standard datagrid that comes with .Net. Also i'm not multithreading so i don't know why its giving me a threading exception.

    I've googled and no results that help me out any.

    Any help would dig me out of a hole lads...Thanks!


Comments

  • Registered Users, Registered Users 2 Posts: 2,426 ✭✭✭ressem


    By default, a windows App created using visual studio will have the attribute
    [STAThread]
    immediately prior to Main.

    Adding it back in will stop this exception from appearing.

    Ctrl-C seems to make a call to System.Reflection that Ctrl X doesn't.

    http://www.syncfusion.com/faq/winforms/search/967.asp
    "
    While the STAThread is required (as the documentation states) and pertinent only to applications that use COM interop, 1.0 version of the .Net framework has some bugs that makes it necessary for you to specify the STAThread attribute:

    1) Ole Drag Drop will not work without STA. You can check this by turning on drag and drop in a form and try to run it.

    2) Invoking a method in a type using Reflection will not work either.
    "

    They say on that page that this is a bug that was sorted on framework 1.1, but apparently not.



    For those more informed than me
    Exception at
    StackTrace " at System.Windows.Forms.Clipboard.SetDataObject(Object data, Boolean copy)\r\n at System.Windows.Forms.Clipboard.SetDataObject(Object data)\r\n at System.Windows.Forms.DataGrid.ProcessDialogKey(Keys keyData)\r\n at System.Windows.Forms.Control.ProcessDialogKey(Keys keyData)\r\n at System.Windows.Forms.TextBoxBase.ProcessDialogKey(Keys keyData)\r\n at System.Windows.Forms.Control.PreProcessMessage(Message& msg)\r\n at System.Windows.Forms.ThreadContext.System.Windows.Forms.UnsafeNativeMethods+IMsoComponent.FPreTranslateMessage(MSG& msg)\r\n at System.Windows.Forms.ComponentManager.System.Windows.Forms.UnsafeNativeMethods+IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)\r\n at System.Windows.Forms.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)\r\n at System.Windows.Forms.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)\r\n at System.Windows.Forms.Application.Run(Form mainForm)\r\n


    Message "The current thread must set to Single Thread Apartment (STA) mode before OLE calls can be made. Ensure that your Main function has STAThreadAttribute marked on it."


Advertisement