DataGridView Index -1 does not have a value 错误
遇到一个非常奇怪的问题,
一个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 错误的更多相关文章
- VS2015中DataGridView的DataGridViewComBoboxCell列值无效及数据绑定错误的解决方法
在VS2015中练习DataGridView的使用, 发现其中的DataGridViewComBoboxCell列存在着绑定数据库列后出现值无效的提示 根据网上的解决办法,添加了DataError后可 ...
- 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 ...
- C# winform DataGridView操作 (转)
C# DataGridView控件动态添加新行 DataGridView控件在实际应用中非常实用,特别需要表格显示数据时.可以静态绑定数据源,这样就自动为DataGridView控件添加相应的行.假如 ...
- 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 ...
- [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 ...
- winform datagridview控件使用
最近做项目时,显示查询结果总需要绑定到datagridview控件上显示,总结了给datagridview绑定数据的方式,以及导出datagridview数据到excel表格,如有错误请多指教 1.直 ...
- 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 ...
- Ubuntu搭建lnmp环境
1.安装nginx 安装 sudo apt-get install nginx 服务启动.停止.重启 /etc/init.d/nginx start /usr/sbin/nginx -c /etc/n ...
- Struts2日期类型转换
针对日期类java.util.Date进行类型转换,要求客户端使用"yyyy-MM-dd","yyyy/MM/dd"中的任意一种输入,并以"yyyy- ...
随机推荐
- 如何使Htm页面使用IE9文档模式
修改Htm页面的方法之一是,在Head->Title下添加<META http-equiv="X-UA-Compatible" content="IE=9&q ...
- NOTE:rfc5766-turn-server
NOTE:This project is active in Google code: http://code.google.com/p/rfc5766-turn-server/ 启动方法:./tur ...
- ssh key 生成
1.设置好git的name和email $ git config --global user.name "姓名" $ git config --global user.email ...
- Android笔记之dp与px之间的转换以及LayoutParams
dp与px之间的转换公式 px = dp * (dpi / 160) dp = px / (dpi / 160) 其中dpi的获取方式如下 private void getDpi() { Displa ...
- Mongoose学习(2)
1.Schema的扩展 UserSchema.methods.findUserName = function(cb){ return this.model('user').find({username ...
- SQL 系统表应用
查看link server select DD.System,DD.DB,DD.previous_processing_dte, DD.processing_dte,LS.LinkServerName ...
- Page Objects
Page Objects 原文地址:https://github.com/SeleniumHQ/selenium/wiki/PageObjects Within your web app's UI t ...
- XMPP学习笔记 -- RFC 6120
XMPP - Extensible Messaging and Presence Protocol 1. 中文版3920 http://wiki.jabbercn.org/RFC3920 2. 大部分 ...
- ubuntu 12.04安装alsa-lib、alsa-utils【转】
1. alsa-lib ./configure sudo make install 注意:默认是安装到/usr/这个目录下面,但是我测试多了多次,安装了alsa-lib之后,系统就没有声音了,也没有找 ...
- SpringMVC+Spring+MyBatis配置
今天配置项目时遇到一个问题,tomcat启动没有报错,但是访问页面的时总是报404,后台打印的日志是: 8080-exec-1] WARN springframework.web.servlet.Pa ...