This is my first attempt at using GCI+. Essentially I need to be able do display ~ 250 rectangles on the screen. Each rectangle's color and location will be determined from a series of calculations within a loop. The loop is called from a button_click event. I'd like to be able to see each rectangle as it's generated, but instead, they build up until the button-click event is completed, then they all appear at once.

This is an abbreviated version of the event, that draws a line across the screen:

private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
graphDrawingArea->DrawRectangle(gcnew Pen(Color::Red), 10, 280, Width - 30, 1);

graphDrawingArea is created when the form is loaded as below (from an example I found on the web).

private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) {
bmpDrawingArea = gcnew Bitmap(Width, Height);
graphDrawingArea = Graphics::FromImage(bmpDrawingArea);

CheckOne() is the main function that does most of the work. If I run this with a breakpoint before CheckOne, nothing appears on the screen until I continue and leave the routine.

Is there code I can insert before the CheckOne call that would make the line appear immediately. Presumably, I could then insert that in my main loop so have the correct rectangles appear.

I've tried various things with Invalidate, InvalidateRect, and .Refresh(), but get either compiler errors, or no change in the results.