DataGridView绑定DataTable出现大红叉
来源:互联网 发布:骑士勇士数据统计 编辑:程序博客网 时间:2024/04/28 04:34
听说:因为主线程创建的控件,在子线程中访问就会出现如下问题;
听说:解决方案可以如下几种:
1.在处理操作DataTable的时候,需要将DataTable锁定;
2.使用 delegate 或者 beginIvoke 的方式來解決;
3.调用自带的Invalidate();
4.加上DataError事件并在其中中加上 try catch;
网上查找的解决方案大致就是酱紫;
因为这情况长时间、偶尔会出现,这在测试中。。。。
异常文本:
************** 异常文本 **************
System.NullReferenceException: 未将对象引用设置到对象的实例。
在 System.Windows.Forms.DataGridViewTextBoxCell.PaintPrivate(Graphics graphics, Rectangle clipBounds, Rectangle cellBounds, Int32 rowIndex, DataGridViewElementStates cellState, Object formattedValue, String errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts, Boolean computeContentBounds, Boolean computeErrorIconBounds, Boolean paint)
在 System.Windows.Forms.DataGridViewTextBoxCell.Paint(Graphics graphics, Rectangle clipBounds, Rectangle cellBounds, Int32 rowIndex, DataGridViewElementStates cellState, Object value, Object formattedValue, String errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts)
在 System.Windows.Forms.DataGridViewCell.PaintWork(Graphics graphics, Rectangle clipBounds, Rectangle cellBounds, Int32 rowIndex, DataGridViewElementStates cellState, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts)
在 System.Windows.Forms.DataGridViewRow.PaintCells(Graphics graphics, Rectangle clipBounds, Rectangle rowBounds, Int32 rowIndex, DataGridViewElementStates rowState, Boolean isFirstDisplayedRow, Boolean isLastVisibleRow, DataGridViewPaintParts paintParts)
在 System.Windows.Forms.DataGridViewRow.Paint(Graphics graphics, Rectangle clipBounds, Rectangle rowBounds, Int32 rowIndex, DataGridViewElementStates rowState, Boolean isFirstDisplayedRow, Boolean isLastVisibleRow)
在 System.Windows.Forms.DataGridView.PaintRows(Graphics g, Rectangle boundingRect, Rectangle clipRect, Boolean singleHorizontalBorderAdded)
在 System.Windows.Forms.DataGridView.PaintGrid(Graphics g, Rectangle gridBounds, Rectangle clipRect, Boolean singleVerticalBorderAdded, Boolean singleHorizontalBorderAdded)
在 System.Windows.Forms.DataGridView.OnPaint(PaintEventArgs e)
在 System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer)
在 System.Windows.Forms.Control.WmPaint(Message& m)
在 System.Windows.Forms.Control.WndProc(Message& m)
在 System.Windows.Forms.DataGridView.WndProc(Message& m)
在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
在 System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
************** 已加载的程序集 **************
mscorlib
程序集版本: 4.0.0.0
Win32 版本: 4.0.30319.1 (RTMRel.030319-0100)
基本代码: file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/mscorlib.dll
----------------------------------------
WCS
程序集版本: 2.0.4575.17354
Win32 版本: 2.0.2.2
基本代码: file:///D:/WCS/WCS.exe
----------------------------------------
System.Windows.Forms
程序集版本: 4.0.0.0
Win32 版本: 4.0.30319.1 built by: RTMRel
基本代码: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
- DataGridView绑定DataTable出现大红叉
- DataGridView出现大红叉--在使用多线程访问数据源时
- DataGridView绑定DataTable,出现索引0没有值的情况
- DataGridView 在多线程中使用可能出现大红叉,解决方法如下
- DataGridView绑定 DataTable 编辑的问题
- c#,vb.net 中datagridview绑定datatable
- C# DataGridView 绑定 DataTable 正确用法
- WinForm中给DataGridView绑定datatable
- 提升 dataGridView 效率,让万笔数据绑定 datatable (dataGridView 中快速导入 datatable)
- eclipse出现大红感叹号问题
- DataGridView 绑定DataTable方式编辑保存的bug
- DataGridView 绑定DataTable方式编辑保存的bug
- DataGridView中绑定DataTable数据及相关操作实现代码
- DataGridView 绑定DataTable方式编辑保存的bug?
- dataGridView直接绑定DataRow数组(导入datatable中)
- c# DataGridView绑定DataTable数据源并指定对应
- DataGridView绑定List<T>,出现IndexOutOfRangeException异常
- DataGridView手动绑定列后出现混乱
- android 沉浸式
- Could not find Developer Disk Image
- [翻译]Spring Cloud Stream
- ubuntu14.04 Thinkpad T450安装wifi
- Shiro学习总结(2)——Apache Shiro快速入门教程
- DataGridView绑定DataTable出现大红叉
- 第7周 C语言程序设计(新2版) 练习1-7 打印一个EOF值
- nyoj19擅长排列的小明(DFS或STL)
- 安卓中的消息循环机制Handler及Looper详解
- Android多次闪退时清除数据
- 笔记-bootstrap span 无效
- Linux下安装theano
- yum和apt-get的区别
- 位运算符