Thread ID: |
Created: |
Updated: |
Platform: |
Replies: |
13894 | May 13,2004 04:28 AM UTC | May 13,2004 10:05 AM UTC | WinForms | 2 |
![]() |
Tags: GridControl |
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim cc As GridCurrentCell = Me.gridDataBoundGrid1.CurrentCell
Dim rs As GridBoundRecordState = Me.gridDataBoundGrid1.Binder.GetRecordStateAtRowIndex(cc.RowIndex)
''add a new record to the child level
Dim o As Object = rs.ListManager.Current
Dim drv As DataRowView = CType(o, DataRowView)
Dim dr As DataRow = drv.Row
If rs.LevelIndex < 2 Then
Dim dt As DataTable = Me.dSet.Tables(rs.LevelIndex + 1) ''get the table
Dim newRow As DataRow = dt.NewRow()
Dim values As Object() = Nothing
Select Case rs.LevelIndex
Case 0
Me.numberOfChildren += 1
''pkValue = this.numberOfChildren;
values = New Object() {Me.numberOfChildren, String.Format("ChildName{0}", Me.numberOfChildren), dr(0)}
Case 1
Me.numberOfGrandChildren += 1
''pkValue = this.numberOfGrandChildren;
values = New Object() {Me.numberOfGrandChildren, String.Format("GrandChildName{0}", numberOfGrandChildren), dr(0), dt.Columns("FavSport").DefaultValue}
Case Else
Throw New IndexOutOfRangeException("Improper index")
End Select
newRow.ItemArray = values
dt.Rows.Add(newRow)
Dim parentLevel As Integer = rs.LevelIndex - 1
If rs.LevelIndex = 0 Then
Me.gridDataBoundGrid1.Model.BeginUpdate()
Dim dt1 As DataTable = Me.gridDataBoundGrid1.DataSource
Me.gridDataBoundGrid1.DataSource = Nothing
Me.gridDataBoundGrid1.DataSource = dt1
Me.gridDataBoundGrid1.EndUpdate()
Else
Dim row As Integer = cc.RowIndex - 1
If row > Me.gridDataBoundGrid1.Model.Rows.HeaderCount Then
Me.gridDataBoundGrid1.Model.BeginUpdate()
Me.gridDataBoundGrid1.CollapseAtRowIndex(row)
Me.gridDataBoundGrid1.ExpandAtRowIndex(row)
Me.gridDataBoundGrid1.CollapseAtRowIndex(row)
Me.gridDataBoundGrid1.ExpandAtRowIndex(row)
Me.gridDataBoundGrid1.Model.EndUpdate()
End If
End If
End If
End Sub
This post will be permanently deleted. Are you sure you want to continue?
Sorry, An error occured while processing your request. Please try again later.
or the page will be automatically redirected to sign-in page in 10 seconds.