gre*_*b64 4 .net c# datagridview visual-c++ winforms
Late Edit 我将此标记为C#问题以及C++,因为问题出现在两种语言中,如果显示的解决方案很可能是在C#(市场的大部分)中.
我一直在.net 2.0下开发一个应用程序(C++具体,但不相关).
此应用程序使用自定义派生的datagridview.此数据网格视图偶尔会出现关于不包含单元格的DGV区域以及滚动条的严重伪像问题. 在一些调整大小的操作,一个黑色的矩形会在DataGridView,这将在作用限制网格的尺寸的底部绘制. 滚动条也缩小以适应非坚固区域.在我看来,因为系统认为DGV尺寸错误,并且正在进入错误的区域.
alt text http://img12.imageshack.us/img12/2213/81356991.jpg
我只能通过两种方法来修复症状:
1.单击要调整大小的列将自动修复网格
2.在DGV中调用AutoResizeRows()函数将执行修复(但我相信是从第1点).
对自定义DGV的一些修改:
1)配置为处理多行的拖放.
2)点1要求重写OnCellPainting以绘制拖动线.如果看起来有症状,可以发布功能.
3)问题总是发生在一个调整大小(手动和自动两种可能会导致问题),但在调整大小事件没有自定义代码.
onCellPainting的后期编辑代码.在gridview中重写的其他函数:OnMouseDown,OnCellMouseDown,OnClick,OnMouseMove,OnDragOver,OnDragDrop,OnDragLeave,OnKeyDown,其中任何一个看起来都没有症状
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
Run Code Online (Sandbox Code Playgroud)
*更多编辑这些都不能解决问题,在问题发生后唯一解决问题的是AutoResizeRows(AllCells)//只有AllCells修复它.这是非常缓慢和不受欢迎的.
刷新(); UpdateBounds(); 更新(); 无效(); PerformLayout(); ResetBackColor(); ResetBindings(); ResetForeColor(); ResetText(); UpdateStyles();
| 归档时间: |
|
| 查看次数: |
4990 次 |
| 最近记录: |