DataGridViewEditingControlShowingEventHandler DataGridViewEditingControlShowingEventHandler DataGridViewEditingControlShowingEventHandler DataGridViewEditingControlShowingEventHandler Delegate

定义

表示将用来处理 EditingControlShowingDataGridView 事件的方法。Represents the method that will handle the EditingControlShowing event of a DataGridView.

public delegate void DataGridViewEditingControlShowingEventHandler(System::Object ^ sender, DataGridViewEditingControlShowingEventArgs ^ e);
public delegate void DataGridViewEditingControlShowingEventHandler(object sender, DataGridViewEditingControlShowingEventArgs e);
type DataGridViewEditingControlShowingEventHandler = delegate of obj * DataGridViewEditingControlShowingEventArgs -> unit
Public Delegate Sub DataGridViewEditingControlShowingEventHandler(sender As Object, e As DataGridViewEditingControlShowingEventArgs)

参数

sender
Object Object Object Object

事件源。The source of the event.

继承
DataGridViewEditingControlShowingEventHandlerDataGridViewEditingControlShowingEventHandlerDataGridViewEditingControlShowingEventHandlerDataGridViewEditingControlShowingEventHandler

示例

下面的代码示例演示如何处理此事件以更改BackColor当前单元格的属性。The following code example illustrates how to handle this event to change the BackColor property of the current cell. 若要运行此示例, 请将代码粘贴到包含DataGridView名为dataGridView1的的窗体中EditingControlShowing , 并确保该事件与事件处理程序相关联。To run this example, paste the code into a form that contains a DataGridView named dataGridView1 and ensure that the EditingControlShowing event is associated with the event handler.

private void dataGridView1_EditingControlShowing(object sender, 
    DataGridViewEditingControlShowingEventArgs e)
{
    e.CellStyle.BackColor = Color.Aquamarine;
}
Private Sub dataGridView1_EditingControlShowing(ByVal sender As Object, _
    ByVal e As DataGridViewEditingControlShowingEventArgs) _
    Handles dataGridView1.EditingControlShowing

    e.CellStyle.BackColor = Color.Aquamarine

End Sub

注解

EditingControlShowing处理事件, 以在单元格进入编辑模式时对编辑控件执行自定义初始化。Handle the EditingControlShowing event to perform custom initialization of the editing control when a cell enters edit mode. 若要自定义控件的显示特性, 请设置由DataGridViewEditingControlShowingEventArgs.CellStyle属性返回的对象的属性, 而不是设置DataGridViewEditingControlShowingEventArgs.Control由属性返回的控件的属性。To customize the display characteristics of the control, set the properties of the object returned by the DataGridViewEditingControlShowingEventArgs.CellStyle property rather than setting the properties of the control returned by the DataGridViewEditingControlShowingEventArgs.Control property.

有关如何处理事件的详细信息, 请参阅处理和引发事件For more information about how to handle events, see Handling and Raising Events.

创建 DataGridViewEditingControlShowingEventHandler 委托时,需要标识将处理该事件的方法。When you create a DataGridViewEditingControlShowingEventHandler delegate, you identify the method that will handle the event. 若要将事件与事件处理程序关联,请将该委托的一个实例添加到事件中。To associate the event with your event handler, add an instance of the delegate to the event. 除非移除了该委托,否则每当发生该事件时就会调用事件处理程序。The event handler is called whenever the event occurs, unless you remove the delegate. 有关事件处理程序委托的详细信息, 请参阅处理和引发事件For more information about event-handler delegates, see Handling and Raising Events.

扩展方法

GetMethodInfo(Delegate) GetMethodInfo(Delegate) GetMethodInfo(Delegate) GetMethodInfo(Delegate)

获取指示指定委托表示的方法的对象。Gets an object that represents the method represented by the specified delegate.

适用于

另请参阅