遇到一个非常奇怪的问题,

一个DataGridView在装载数据后, 无论点击Column还是Cell都会报如下错误:

查bing之后发现StackOverFlow都指向DataSource的问题。

于是查看自己的写法:

    var vt = dgvSummary.DataSource as List<MyTradeSummaryAtom>;
{
var atom = arg_atom;
if (null == atom.Strategy)
return ErrorObject.ReturnFalse("arg_atom的Strategy为Null");
var a = (atom.Strategy as Strategy_V1A1).Account;
var eo = ErrorObject.True;
var tsi = a.GetTradeSummaryInfo(_dtimeStart, _dtimeNext, out eo, 20000);
if (eo.IsFalse)
return eo;
vt.Add(tsi.全部交易概要.ToMyTradeSummaryAtom(atom));
} this.InvokeEx(() =>
{
dgvSummary.DataSource = null;
dgvSummary.DataSource = vt;
}
);

可以看到dgvSummary的DataSource在更新数据前后的对象其实是同一个List

改为:

    this.InvokeEx(() =>
{
dgvSummary.DataSource = vt.ToArray();
}

问题解决

DataGridView Index -1 does not have a value 错误的更多相关文章

  1. VS2015中DataGridView的DataGridViewComBoboxCell列值无效及数据绑定错误的解决方法

    在VS2015中练习DataGridView的使用, 发现其中的DataGridViewComBoboxCell列存在着绑定数据库列后出现值无效的提示 根据网上的解决办法,添加了DataError后可 ...

  2. pandas里面过滤列出现ValueError: cannot index with vector containing NA / NaN values错误的解决方法(转)

    ###df_18的字段fuek是否包含 / df_18[df_18['fuel'].str.contains('/')] 报错: ValueError Traceback (most recent c ...

  3. C# winform DataGridView操作 (转)

    C# DataGridView控件动态添加新行 DataGridView控件在实际应用中非常实用,特别需要表格显示数据时.可以静态绑定数据源,这样就自动为DataGridView控件添加相应的行.假如 ...

  4. ALTER TABLE SWITCH' statement failed. The table x' is partitioned while index 'x' is not partitioned.

    1.L_Monitoring有这么些字段,ID,Collecttime,PlateType,PlateNO以及其他一些这段.建立这个表的时候是个非分区表,其中ID是主键,并在Collecttime,P ...

  5. [20180317]12c TABLE ACCESS BY INDEX ROWID BATCHED2.txt

    [20180317]12c TABLE ACCESS BY INDEX ROWID BATCHED2.txt --//简单探究12c TABLE ACCESS BY INDEX ROWID BATCH ...

  6. winform datagridview控件使用

    最近做项目时,显示查询结果总需要绑定到datagridview控件上显示,总结了给datagridview绑定数据的方式,以及导出datagridview数据到excel表格,如有错误请多指教 1.直 ...

  7. werkzeug.routing.BuildError: Could not build url for endpoint 'index'. Did you mean 'user.index' instead?

    werkzeug.routing.BuildError: Could not build url for endpoint 'index'. Did you mean 'user.index' ins ...

  8. Ubuntu搭建lnmp环境

    1.安装nginx 安装 sudo apt-get install nginx 服务启动.停止.重启 /etc/init.d/nginx start /usr/sbin/nginx -c /etc/n ...

  9. Struts2日期类型转换

    针对日期类java.util.Date进行类型转换,要求客户端使用"yyyy-MM-dd","yyyy/MM/dd"中的任意一种输入,并以"yyyy- ...

随机推荐

  1. 使用Entity Framework和WCF Ria Services开发SilverLight之6:查找指定字段

    对数据库表指定字段的查找,又是实际工作中的一项必要工作.SL客户端仅获取实际需要的指定的字段,好处很多,比如:有助于减少网络流量. 有两类这样的使用场景. 1:联表查询不需要外键表 在上一篇中,我们使 ...

  2. iOS开发之──传感器使用

    本文转载至 http://mobile.51cto.com/iphone-423219.htm 在实际的应用开发中,会用到传感器,下面首先介绍一下iphone4的传感器,然后对一些传感器的开发的API ...

  3. java验证码问题

    AuthImageServlet.java package com.util.servlet; import java.awt.Color;import java.awt.Font;import ja ...

  4. 03-树2 List Leaves(25 point(s)) 【Tree】

    03-树2 List Leaves(25 point(s)) Given a tree, you are supposed to list all the leaves in the order of ...

  5. LightOJ1220 —— 质因数分解

    题目链接:https://vjudge.net/problem/LightOJ-1220 1220 - Mysterious Bacteria    PDF (English) Statistics ...

  6. CodeChef Forest Gathering —— 二分

    题目链接:https://vjudge.net/problem/CodeChef-FORESTGA 题解: 现场赛.拿到这题很快就知道是二分,但是一直wa,怎么修改也wa,后来又换了种错误的思路,最后 ...

  7. gzhu 2013 Good Sequence 解题报告

    题目链接:(这个是内网的网址)  http://172.22.27.1/problem?pid=1013 Good Sequence Time Limit: 4000/2000 MS (Java/Ot ...

  8. html5--5-11 绘制文字

    html5--5-11 绘制文字 学习要点 掌握文字的绘制方法 文字的绘制方法 strokeText("文字",x,y,maxWith) 绘制(描边)空心文字 fillText(& ...

  9. 万亿级日志与行为数据存储查询技术剖析(续)——Tindex是改造的lucene和druid

    五.Tindex 数果智能根据开源的方案自研了一套数据存储的解决方案,该方案的索引层通过改造Lucene实现,数据查询和索引写入框架通过扩展Druid实现.既保证了数据的实时性和指标自由定义的问题,又 ...

  10. hdu-5003 Osu!(水题)

    题目链接: Osu! time Limit: 2000/1000 MS (Java/Others)     Memory Limit: 65536/65536 K (Java/Others) Prob ...