本文整理汇总了VB.NET中System.Data.DataColumn.Expression属性的典型用法代码示例。如果您正苦于以下问题:VB.NET DataColumn.Expression属性的具体用法?VB.NET DataColumn.Expression怎么用?VB.NET DataColumn.Expression使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类System.Data.DataColumn
的用法示例。
在下文中一共展示了DataColumn.Expression属性的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。
示例1: CalcColumns
Private Sub CalcColumns()
Dim rate As Single = .0862
Dim table As New DataTable()
' Create the first column.
Dim priceColumn As New DataColumn()
With priceColumn
.DataType = System.Type.GetType("System.Decimal")
.ColumnName = "price"
.DefaultValue = 50
End With
' Create the second, calculated, column.
Dim taxColumn As New DataColumn()
With taxColumn
.DataType = System.Type.GetType("System.Decimal")
.ColumnName = "tax"
.Expression = "price * 0.0862"
End With
' Create third column
Dim totalColumn As New DataColumn()
With totalColumn
.DataType = System.Type.GetType("System.Decimal")
.ColumnName = "total"
.Expression = "price + tax"
End With
' Add columns to DataTable
With table.Columns
.Add(priceColumn)
.Add(taxColumn)
.Add(totalColumn)
End With
Dim row As DataRow= table.NewRow
table.Rows.Add(row)
Dim view As New DataView
view.Table = table
DataGrid1.DataSource = view
End Sub