现在DataGrid(WinForm)的DataSorce设为DataView,DataView中有数据,而且DataGrid的CurrentRow也取到值,但就是DataGrid显示不出来。
谢谢
谢谢
解决方案 »
- 如何将C#运行结果的整个Form窗体都保存下来?
- C#如何高效率的比较两个IP地址的大小
- c#中如何直接读到文本文件的最后一行
- 关于线程中控制进度条问题内.
- 在ASP.NET 2.0 中GridView 为什么不显示数据类型为image 的列
- 关于自定义事件的一个小问题
- 急需infragistics netadvantage 2004 的中文教程,谢谢!
- 关于线程和 Invoke() 方法
- 请问怎样做一个查询系统?
- 目前是不是有一个叫j#.net 的东西啊?
- 如何实现当传过来一个值和GridView的某一行主键值相等时候,该行颜色变化?
- ^^^数组保存TextBox的问题^^^^ ++++100分++++
dg.SetDataBinding(ds, "tablename");或是dg.SetDataBinding(ds.Tables[0], null);
而是要采用DataGrid的SetDataBinding()方法来执行绑定,当然如果你要是指定了TableStyle,也必须把MappingName和你绑定的表名一致才可以
DataGrid.DataBind()
DataTable dt = this.CreateQueryResultDT(begin,end);
this.dg_result.DataSource = dt.DefaultView;this.dg_result.CaptionText = "查询统计";DataGridTableStyle ts = new DataGridTableStyle();
ts.MappingName = dt.TableName;#region 增加TableStyles列DataGridTextBoxColumn col;//增加日期列
col = new DataGridTextBoxColumn();
col.HeaderText = "发生日期";
col.MappingName = "occurdate";
col.ReadOnly = true;
col.Width = 120;
ts.GridColumnStyles.Add(col);//增加名称列
col = new DataGridTextBoxColumn();
col.HeaderText = "名称";
col.MappingName = "name";
col.ReadOnly = true;
col.Width = 200;
ts.GridColumnStyles.Add(col);#endregion//设置样式
ts.AlternatingBackColor = Color.SkyBlue;
ts.AllowSorting = false;this.dg_result.TableStyles.Add(ts);
dategrid1.datamember="yourtablename";