Later editing I noted this as a question of C #, as well as C ++, because the problem occurs in both languages, and the solution, if shown, will most likely be in C # (most of the market).
I am developing an application for .net 2.0 (C ++ is specific, but irrelevant).
This app uses a custom datagridview. This datagridview will sometimes have artifact problems with respect to a DGV area that does not contain cells, as well as a scroll bar. During some resizing actions, a black rectangle will draw at the bottom of the datagridview window, which actually limits the size of the grid. The scrollbar also becomes compressed to fit into an unsupported region. It seems to me that the system believes that the DGV is the wrong size and is drawn into the wrong region.
alt text http://img12.imageshack.us/img12/2213/81356991.jpg
There are only two ways I can find to correct the symptoms:
1. Clicking on a column to resize automatically locks the grid
2. Calling the AutoResizeRows () function in DGV will make a correction (but I believe that this is what is called from point 1).
Some changes to Custom DGV:
1) Configured to handle drag \ drop from multiple lines.
2) Point 1 requires that OnCellPainting be overridden to draw drag lines. A function may be published if it seems symptomatic.
3) Problems always arise when resizing (both manually and automatically can cause a problem), but there is no user code in the resize event.
late editing code for onCellPainting. Other functions overridden in gridview: OnMouseDown, OnCellMouseDown, OnClick, OnMouseMove, OnDragOver, OnDragDrop, OnDragLeave, OnKeyDown, none of which seem symptomatic
protected: [DebuggerStepThrough()] virtual System::Void OnCellPainting(DataGridViewCellPaintingEventArgs ^e) override { //draws red drag/drop target indicator lines if necessary if (this->AllowDrop && _DragDropCurrentIndex > -1 && ShowDragLines) { System::Drawing::Pen ^p = gcnew Pen(System::Drawing::Color::Navy, 3); //row drag/drop if (e->RowIndex == _DragDropCurrentIndex && _DragDropCurrentIndex <= this->RowCount) { //if this cell is in the same row as the mouse cursor e->Graphics->DrawLine( p, e->CellBounds.Left, e->CellBounds.Top - 1, e->CellBounds.Right, e->CellBounds.Top - 1); } //end if if(e->RowIndex == this->Rows->Count - 1 && _DragDropCurrentIndex == Int32::MaxValue) { e->Graphics->DrawLine( p, e->CellBounds.Left, e->CellBounds.Bottom + 1, e->CellBounds.Right, e->CellBounds.Bottom + 1); } } //end if DataGridView::OnCellPainting(e); } //end OnCellPainting
* Additional changes None of these features helps to fix the problem, the only thing that fixes it. AFTER a problem occurs - AutoResizeRows (AllCells) // Only AllCells fixes it. It is very slow and undesirable.
Refresh (); UpdateBounds (); Refresh (); Invalidate (); PerformLayout (); ResetBackColor (); ResetBindings (); ResetForeColor (); ResetText (); UpdateStyles ();