'宣言 Public Overloads Function Delete( _ ByVal displayPrompt As Boolean _ ) As Boolean
public bool Delete( bool displayPrompt )
行が削除される際、BeforeRowsDeleted イベントが生成されます。その後、行はコントロールから削除されて、それに対応するレコードもデータソースから削除されます。レコードをデータソースから削除できない場合は、Error イベントが生成されます。
コントロールの DeleteSelectedRows メソッドを呼び出せば、選択されたすべての行を削除できます。
Imports Infragistics.Shared Imports Infragistics.Win Imports Infragistics.Win.UltraWinGrid Private Sub Button69_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles button69.Click ' Get the row to delete. In this case we will use the active row. Dim row As UltraGridRow = Me.UltraGrid1.ActiveRow If Not row Is Nothing Then ' Delete the row by calling Delete method. Enclose the call in a try-catch ' block so if there is an error, we can catch it and show an error message box ' to the user. Try row.Delete() ' IsDeleted should be true after a row has been deleted. Debug.WriteLine("Row.IsDeleted = " & row.IsDeleted) Catch exc As Exception MessageBox.Show("Error occured during deleting the row.\n" & exc.Message, _ "Error deleting row", MessageBoxButtons.OK, MessageBoxIcon.Error) End Try Else ' If there is no active row, then prompt the user to select one. MessageBox.Show("Please select a single row to delete.") End If End Sub
using Infragistics.Shared; using Infragistics.Win; using Infragistics.Win.UltraWinGrid; using System.Diagnostics; private void button69_Click(object sender, System.EventArgs e) { // Get the row to delete. In this case we will use the active row. UltraGridRow row = this.ultraGrid1.ActiveRow; if ( null != row ) { // Delete the row by calling Delete method. Enclose the call in a try-catch // block so if there is an error, we can catch it and show an error message box // to the user. try { row.Delete( ); // IsDeleted should be true after a row has been deleted. Debug.WriteLine( "Row.IsDeleted = " + row.IsDeleted ); } catch ( Exception exc ) { MessageBox.Show( "Error occured during deleting the row.\n" + exc.Message, "Error deleting row", MessageBoxButtons.OK, MessageBoxIcon.Error ); } } else { // If there is no active row, then prompt the user to select one. MessageBox.Show( "Please select a single row to delete." ); } }