DataGridViewRowCancelEventArgs Класс

Определение

Предоставляет данные для события UserDeletingRow объекта DataGridView.

public ref class DataGridViewRowCancelEventArgs : System::ComponentModel::CancelEventArgs
public class DataGridViewRowCancelEventArgs : System.ComponentModel.CancelEventArgs
type DataGridViewRowCancelEventArgs = class
    inherit CancelEventArgs
Public Class DataGridViewRowCancelEventArgs
Inherits CancelEventArgs
Наследование
DataGridViewRowCancelEventArgs

Примеры

В следующем примере кода показано использование этого типа. Этот пример является частью более крупного примера, доступного в разделе Практическое руководство. Реализация виртуального режима в элементе управления Windows Forms DataGridView.

void dataGridView1_UserDeletingRow( Object^ /*sender*/,
    System::Windows::Forms::DataGridViewRowCancelEventArgs^ e )
{
   if ( e->Row->Index < this->customers->Count )
   {
      
      // If the user has deleted an existing row, remove the 
      // corresponding Customer object from the data store.
      this->customers->RemoveAt( e->Row->Index );
   }

   if ( e->Row->Index == this->rowInEdit )
   {
      
      // If the user has deleted a newly created row, release
      // the corresponding Customer object. 
      this->rowInEdit = -1;
      this->customerInEdit = nullptr;
   }
}
private void dataGridView1_UserDeletingRow(object sender,
    System.Windows.Forms.DataGridViewRowCancelEventArgs e)
{
    if (e.Row.Index < this.customers.Count)
    {
        // If the user has deleted an existing row, remove the 
        // corresponding Customer object from the data store.
        this.customers.RemoveAt(e.Row.Index);
    }

    if (e.Row.Index == this.rowInEdit)
    {
        // If the user has deleted a newly created row, release
        // the corresponding Customer object. 
        this.rowInEdit = -1;
        this.customerInEdit = null;
    }
}
Private Sub dataGridView1_UserDeletingRow(ByVal sender As Object, _
    ByVal e As System.Windows.Forms.DataGridViewRowCancelEventArgs) _
    Handles dataGridView1.UserDeletingRow

    If e.Row.Index < Me.customers.Count Then

        ' If the user has deleted an existing row, remove the 
        ' corresponding Customer object from the data store.
        Me.customers.RemoveAt(e.Row.Index)

    End If

    If e.Row.Index = Me.rowInEdit Then

        ' If the user has deleted a newly created row, release
        ' the corresponding Customer object. 
        Me.rowInEdit = -1
        Me.customerInEdit = Nothing

    End If

End Sub

Комментарии

Чтобы отменить удаление строки в обработчике UserDeletingRow событий, присвойте свойству Cancel значение true.

Дополнительные сведения об обработке событий см. в разделе Обработка и создание событий.

Конструкторы

DataGridViewRowCancelEventArgs(DataGridViewRow)

Инициализирует новый экземпляр класса DataGridViewRowCancelEventArgs.

Свойства

Cancel

Возвращает или задает значение, показывающее, следует ли отменить событие.

(Унаследовано от CancelEventArgs)
Row

Возвращает строку, удаляемую пользователем.

Методы

Equals(Object)

Определяет, равен ли указанный объект текущему объекту.

(Унаследовано от Object)
GetHashCode()

Служит хэш-функцией по умолчанию.

(Унаследовано от Object)
GetType()

Возвращает объект Type для текущего экземпляра.

(Унаследовано от Object)
MemberwiseClone()

Создает неполную копию текущего объекта Object.

(Унаследовано от Object)
ToString()

Возвращает строку, представляющую текущий объект.

(Унаследовано от Object)

Применяется к

См. также раздел