Application::DoEvents() GridView

This is a discussion on Application::DoEvents() GridView within the C++ Programming forums, part of the General Programming Boards category; I am using this code to let a cell in a dataGridView "blink" in yellowgreen color and then back to ...

  1. #1
    Registered User
    Join Date
    Oct 2008
    Posts
    59

    Application::DoEvents() GridView

    I am using this code to let a cell in a dataGridView "blink" in yellowgreen color and then back to Black.
    I am using Sleep() and Application:oEvents() to update the grid.

    When using the Application:oEvents() all cells can have a tendence to "blink" wich look a bit strange when I only want to update ->Cells[0].

    Is there another way to do this to prevent the whole dataGrids Cells to "blink" ?


    Code:
    dataGridView1->Rows[e->RowIndex]->Cells[0]->Style->BackColor = Color::YellowGreen;
    
    Application::DoEvents();
    
    Thread::Sleep(50);
    
    dataGridView1->Rows[e->RowIndex]->Cells[0]->Style->BackColor = Color::Black;
    
    Application::DoEvents();

  2. #2
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,292
    It's been a little while since I programmed in VB, but DoEvents is generally a bad thing to call. There are very limited circumstances where it wont introduce an obscure or even obvious bug. Most of the time it should be avoided, and that's just counting the places where you think you really need it. Sorry I don't have time to search for articles explaining it all at the moment.
    There is probably some update method on the control you can call instead or something.
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. bind ArrayList to GridView
    By khdani in forum C# Programming
    Replies: 1
    Last Post: 04-26-2009, 11:49 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21