[VB.NET]关于DataGridView的问题,会的请进来看看,帮忙解决!!

前端之家收集整理的这篇文章主要介绍了[VB.NET]关于DataGridView的问题,会的请进来看看,帮忙解决!!前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
关于DataGridView的问题,会的请进来看看,帮忙解决!! 代码如下: Private sub Binddg() Try sqlAda.SelectCommand = sqlcmd ds.Clear() sqlAda.Fill(ds) Me.DataGridView1.TableStyles(0).MappingName = ds.Tables(0).Tables (0).TableName.Trim() Me.DataGridView1.DataSource = ds.Tables(0) Me.DataGridView1.CurrentCell = New DataGridCell(0,1) dt_row = ds.Tables(0).Rows.Count dt_col = ds.Tables(0).Columns.Count s = False Catch ex As Exception Sample02.writeErr(ex) End Try End Sub 该函数的作用是将数据源与DataGridView1控件绑定,但代码写完后,系统提示错误: 1: "tablestyles "不是“System.Windows.Forms.DataGridView”的成员. 2:类型“System.Windows.Forms.DataGridCell”的值无法转换“System.Windows.Forms.DataGridViewCell”. " __________________________________________________________________________ 哪位高手能解决这两大错误,小弟不胜感激!! __________________________________________________________________________ 楼主注意区分: DataGrid 和 DataGridView.应该是两个不同的控件。 所以: 1: "tablestyles "不是“System.Windows.Forms.DataGridView”的成员. 2:类型“System.Windows.Forms.DataGridCell”的值无法转换“System.Windows.Forms.DataGridViewCell”. " __________________________________________________________________________ 相当于把一个类型的数据赋给另一个类型,所以会报错啊。 __________________________________________________________________________ DataGrid和DataView是不同的控件了,控件不同的数据类型也不同。以前在2003中只有DataGrid。。。。。。 __________________________________________________________________________ Me.DataGridView1.TableStyles(0).MappingName = ds.Tables(0).Tables (0).TableName.Trim() Me.DataGridView1.DataSource = ds.Tables(0) Me.DataGridView1.CurrentCell = New DataGridCell(0,1) 那试问这几行代码的含义是什么啊,大家能猜猜究竟干什么用的吗? __________________________________________________________________________ DataGrid和DataGridView是不同的两个控件,DataGridView是VS2005才有的 Me.DataGridView1.TableStyles(0).MappingName = ds.Tables(0).Tables (0).TableName.Trim() TableStyles是DataGrid的表样式,DataGridView控件是没有这个对象的,所以报错:1: "tablestyles "不是“System.Windows.Forms.DataGridView”的成员. Me.DataGridView1.DataSource = ds.Tables(0) 是设DataGridView1的数据源为数据集ds中的第一张表Tables(0) Me.DataGridView1.CurrentCell = New DataGridCell(0,1) 是设DataGridView1的当前单元格是那一格,但这里是DataGrid控件的设置方法,所以报错:2:类型“System.Windows.Forms.DataGridCell”的值无法转换“System.Windows.Forms.DataGridViewCell”. " DataGridView控件可以这样设 Me.DataGridView1.CurrentCell = Me.DataGridView1.Rows(0).Cells(1) __________________________________________________________________________ DataGrid和DataView是不同的控件了,控件不同的数据类型也不同。以前在2003中只有DataGrid。。。。。。 那按楼主说2005两个控件都有。。。。。 __________________________________________________________________________ up top __________________________________________________________________________ 映射 到MSDN ms-help://MS.MSDNQTR.v80.chs/MS.MSDN.v80/MS.VisualStudio.v80.chs/dv_raddata/html/fb4cec1e-f3c8-4773-b409-c2de15293fea.htm __________________________________________________________________________ 原文链接:https://www.f2er.com/vb/264059.html

猜你在找的VB相关文章