动态增加和删除DataGrid中的行

作者在 2007-04-17 23:11:00 发布以下内容

'*type为1表示要增加行 2为减去行
    Private Sub rowChange(ByVal type As Integer,byval GridType as DataGrid)
        Select Case type
            Case 1
                GridType.DataSource = CreateDataSource(Me.GridType.Items.Count + 1)
                GridType.DataBind()
            Case 2
                GridType.DataSource = CreateDataSource(Me.GridType.Items.Count - 1)
                GridType.DataBind()
        End Select
    End Sub

CreateDataSource(ByVal h As Integer) As ICollection
        Dim dt As New DataTable
        Dim dr As DataRow
        Dim i As Integer
        For i = 0 To h - 1
            dr = dt.NewRow()
            dt.Rows.Add(dr)
        Next i
        Dim dv As New DataView(dt)
        Return dv
End

VB.NET | 阅读 780 次
文章评论,共0条
游客请输入验证码
最新评论