Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. Invoke method on a datagridview control !

Invoke method on a datagridview control !

Scheduled Pinned Locked Moved C#
helptutorialquestion
3 Posts 2 Posters 2 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    Hussam Fattahi
    wrote on last edited by
    #1

    I'm writing a multithreaded application, and in some phase in my program i have to add a row to the datagridview control from thread other than the thread the control created in, but when using this line of code

        Control.CheckForIllegalCrossThreadCalls = false;
    

    when the rows count comes out of the datagridview control visible area,and then try to add a row the program stuck on screen (NotResponding). so i want to know how to call an invoke method on a datagridview control to add a row? in order to make the call a thread safe. thanks in advance,

    L 1 Reply Last reply
    0
    • H Hussam Fattahi

      I'm writing a multithreaded application, and in some phase in my program i have to add a row to the datagridview control from thread other than the thread the control created in, but when using this line of code

          Control.CheckForIllegalCrossThreadCalls = false;
      

      when the rows count comes out of the datagridview control visible area,and then try to add a row the program stuck on screen (NotResponding). so i want to know how to call an invoke method on a datagridview control to add a row? in order to make the call a thread safe. thanks in advance,

      L Offline
      L Offline
      Luc Pattyn
      wrote on last edited by
      #2

      Hi, the InvokeRequired property and Invoke/BeginInvoke methods work the same on all controls, you can find many articles about that subject. Both of my articles also show a very simple example; I recommend you look at MainForm.cs in the Sokoban article. You must follow the rules here; if you dont, it may or may not work on .NET 1.x (not work here means freeze); on .NET 2.0 and above, it will throw an exception. :)

      Luc Pattyn [My Articles]

      H 1 Reply Last reply
      0
      • L Luc Pattyn

        Hi, the InvokeRequired property and Invoke/BeginInvoke methods work the same on all controls, you can find many articles about that subject. Both of my articles also show a very simple example; I recommend you look at MainForm.cs in the Sokoban article. You must follow the rules here; if you dont, it may or may not work on .NET 1.x (not work here means freeze); on .NET 2.0 and above, it will throw an exception. :)

        Luc Pattyn [My Articles]

        H Offline
        H Offline
        Hussam Fattahi
        wrote on last edited by
        #3

        thanks alot

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups