Imports Infragistics.Shared
Imports Infragistics.Win
Imports Infragistics.Win.UltraWinGrid
Imports System.Diagnostics
Private Sub UltraGrid1_BeforeRowInsert(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinGrid.BeforeRowInsertEventArgs) Handles ultraGrid1.BeforeRowInsert
' 行を追加するために新規追加ボタンがクリックされたときに、
' BeforeRowInsert を発生しますこのイベントでは、条件的に行の追加を回避するために、
' Cancel を True に設定できます
' 行が追加される行コレクションにもアクセスできます
Dim rowsColl As RowsCollection = Nothing
If Nothing Is e.ParentRow Then
' ParentRow が null の場合、行は一番上の行コレクションに追加されます
' UltraGrid の Rows プロパティを使用してアクセスできます
rowsColl = Me.ultraGrid1.Rows
Else
' ParentRow が null でない場合、行は子孫バンドに追加されますここに
' 行コレクションを取得します
rowsColl = e.ParentRow.ChildBands(e.Band).Rows
End If
Debug.WriteLine("Row is being added to rows collection with " & rowsColl.Count.ToString() & " number of rows.")
Dim result As DialogResult = MessageBox.Show("You are about to add a row to " & e.Band.Key & ". Continue ?", _
"Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
' UltraGrid で行の追加を中止するために Cancel を True に設定します
If DialogResult.No = result Then
e.Cancel = True
End If
End Sub