data table 手动添加列及行
2016-04-28 23:43
253 查看
前端的data table,自行添加列,不与任何数据源连接。
Public Sub DTAddColumn(ByRef oDataTable As DataTable, ByVal strFieldName As String, ByVal oFieldType As enuFieldType, Optional ByVal intFieldLength As Integer = 0)
Dim oColumn As New DataColumn
Dim strType As String = GetTypeName(enuTypeList.TLFieldType, oFieldType)
With oColumn
.ColumnName = strFieldName
.DataType = System.Type.GetType("System." & strType)
Select Case oFieldType
Case enuFieldType.FTString
If intFieldLength = 0 Then
intFieldLength = gcintFieldStringLength
End If
.MaxLength = intFieldLength
Case enuFieldType.FTBoolean
.DefaultValue = False
End Select
End With
Call oDataTable.Columns.Add(oColumn)
End Sub
代码添加行:
Dim oRow As DataRow
oRow = moDT.NewRow
With oRow
.Item("cPath") = oFile.DirectoryName
.Item("cName") = oFile.Name
.Item("dDate") = oFile.LastWriteTime
End With
moDT.Rows.Add(oRow)
Public Sub DTAddColumn(ByRef oDataTable As DataTable, ByVal strFieldName As String, ByVal oFieldType As enuFieldType, Optional ByVal intFieldLength As Integer = 0)
Dim oColumn As New DataColumn
Dim strType As String = GetTypeName(enuTypeList.TLFieldType, oFieldType)
With oColumn
.ColumnName = strFieldName
.DataType = System.Type.GetType("System." & strType)
Select Case oFieldType
Case enuFieldType.FTString
If intFieldLength = 0 Then
intFieldLength = gcintFieldStringLength
End If
.MaxLength = intFieldLength
Case enuFieldType.FTBoolean
.DefaultValue = False
End Select
End With
Call oDataTable.Columns.Add(oColumn)
End Sub
代码添加行:
Dim oRow As DataRow
oRow = moDT.NewRow
With oRow
.Item("cPath") = oFile.DirectoryName
.Item("cName") = oFile.Name
.Item("dDate") = oFile.LastWriteTime
End With
moDT.Rows.Add(oRow)
相关文章推荐
- LeetCode: 343. Integer Break
- 剖析你的“环境”,是如何保存数据的,大端Or小端
- [杂谈]这个四月
- ZOJ 7th Anniversary Contest
- 328.LeetCode_Linked List_Odd Even Linked List
- SpannableString属性详解
- Json工具类 ---JsonUtil
- Servlet的使用方法详细说明
- 通过PHP操作Redis的简单使用--Redis学习笔记七
- robotframework 常用快捷键
- kafka远程客户端 运行producer线程 时报 Unable to connect to zookeeper server within timeout: 400
- SonarQube代码质量管理平台安装与使用
- springMVC(7)------springMVC处理模型数据
- Spring开篇(一)
- 利用Python的PIL库进行简单的图像处理
- 菱形图案的输出
- IO总结
- Cobertura代码覆盖率测试
- cell重用机制
- Java数据结构初试之自定义自己的链表结构类