欢迎您来到GIS动力

加入收藏 免费注册 用户登陆 帮助中心
首页 新闻动态 技术专栏 银杏树下 学习考研 软件下载 求职招聘 许愿瓶 节日祝福 用户中心 精彩推荐 资源搜索 地图
专栏导航: AO开发 | SO开发 | ArcGIS桌面 | 超图桌面 | 开发语言 | 数据库 | WebGIS | 银杏文学 | 研究生考题 | FreeMap 谈天说地
   您现在位于: 首页技术专栏ArcGIS应用与开发AO开发 → 正文
DataTable对象
07-12-06 00:00:00 作者:浩淼的天空 出处:浩淼的天空
在考虑这个方法的时候,曾经遇到过很多误区,一开始我总是相让属性表以上下结构显示,即上面是表头是属性名,而表中有一行数据来显示各个属性:
------|--------|-----------
ID NAME AGE
------|--------|-----------
001 JACK 20
------|--------|-----------
但是实际使用的时候却麻烦多多,对于不同的要素类而言,我们没有办法规定要素类属性的数目,曾经考虑使用Hash表,链表等多种数据结构,还是不好解决这个问题,最后回到开始,还是采用左边为属性名,右边为属性的方法:
在VB.NET中代码如下:
' 产生一个数据表
Dim myDataTable As DataTable = New DataTable("ParentTable")
' Declare variables for DataColumn and DataRow objects.
Dim myDataColumn As DataColumn
Dim myDataRow As DataRow

' Create new DataColumn, set DataType, ColumnName and add to DataTable.
myDataColumn = New DataColumn
myDataColumn.DataType = System.Type.GetType("System.String")
myDataColumn.ColumnName = "属性名"
myDataColumn.ReadOnly = True
myDataColumn.Unique = True
' Add the Column to the DataColumnCollection.
myDataTable.Columns.Add(myDataColumn)

' Create second column.
myDataColumn = New DataColumn
myDataColumn.DataType = System.Type.GetType("System.String")
myDataColumn.ColumnName = "属性"
myDataColumn.AutoIncrement = False
myDataColumn.Caption = "ParentItem"
myDataColumn.ReadOnly = False
myDataColumn.Unique = False
' Add the column to the table.
myDataTable.Columns.Add(myDataColumn)

' Instantiate the DataSet variable.
myDataSet = New DataSet
' Add the new DataTable to the DataSet.
myDataSet.Tables.Add(myDataTable)

' Create three new DataRow objects and add them to the DataTable
Dim i As Integer
For i = 0 To 100
myDataRow = myDataTable.NewRow()
myDataRow("id") = i
myDataRow("ParentItem") = "ParentItem " + i.ToString()
myDataTable.Rows.Add(myDataRow)
Next i

DataGrid1.SetDataBinding(myDataSet, "ParentTable")

GridControl1.DataSource = myDataSet
GridControl1.DataMember = "parenttable"
GridControl1.MainView.PopulateColumns()
GridControl1是一种独特的表格控件,数据的填充也是随意的,但其主要过程就是产生一个有两个字段的表,然后填充数据,放入到GridControl1中去.

(本文已被浏览 次)
发布人:admin
推荐给好友:发送给好友
上篇新闻:
下篇新闻:
相关评论
发表我的评论
  • 尊重网上道德,遵守《全国人大常委会关于维护互联网安全的决定》及中华人民共和国其他各项有关法律法;
  • 本站有权保留或删除您发表的任何评论内容;
  •   相关文章  

    关于我们 友情链接 ┋ 与我在线 ┋ 管理 ┋ TOP
    网站当前版本:GisPower CMS V3.0
    『GIS 动力』- http://www.gispower.org/
    联系我们:webmaster#gispower.org
    Copyright (c) 2003-2007 GisPOwer.Org. All Rights Reserved.

                   滇ICP备05006901号