IDataGridViewEditingControl.ApplyCellStyleToEditingControl(DataGridViewCellStyle) 方法

定义

更改控件的用户界面 (UI),使之与指定单元格样式一致。Changes the control's user interface (UI) to be consistent with the specified cell style.

public:
 void ApplyCellStyleToEditingControl(System::Windows::Forms::DataGridViewCellStyle ^ dataGridViewCellStyle);
public void ApplyCellStyleToEditingControl (System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle);
abstract member ApplyCellStyleToEditingControl : System.Windows.Forms.DataGridViewCellStyle -> unit

参数

dataGridViewCellStyle
DataGridViewCellStyle

用作用户界面模型的 DataGridViewCellStyleThe DataGridViewCellStyle to use as the model for the UI.

示例

下面的代码示例提供了此成员的实现。The following code example provides an implementation of this member. 此示例摘自了如何:Windows 窗体 DataGridView 单元中的主机控件。This example is part of a larger example available in How to: Host Controls in Windows Forms DataGridView Cells.

// Implements the 
// IDataGridViewEditingControl.ApplyCellStyleToEditingControl method.
public void ApplyCellStyleToEditingControl(
    DataGridViewCellStyle dataGridViewCellStyle)
{
    this.Font = dataGridViewCellStyle.Font;
    this.CalendarForeColor = dataGridViewCellStyle.ForeColor;
    this.CalendarMonthBackground = dataGridViewCellStyle.BackColor;
}
Public Sub ApplyCellStyleToEditingControl(ByVal dataGridViewCellStyle As _
    DataGridViewCellStyle) _
    Implements IDataGridViewEditingControl.ApplyCellStyleToEditingControl

    Me.Font = dataGridViewCellStyle.Font
    Me.CalendarForeColor = dataGridViewCellStyle.ForeColor
    Me.CalendarMonthBackground = dataGridViewCellStyle.BackColor

End Sub

注解

通常, 此方法的实现会将编辑控件 (如字体、背景色和前景色) 的 UI 属性设置为中dataGridViewCellStyle的相应属性的值, 这是用于承载的单元格的样式。控件.Typically, an implementation of this method will set UI properties for the editing control, such as font, background color, and foreground color, to the values of corresponding properties in the dataGridViewCellStyle, which is the style used for the cell hosting the control.

适用于

另请参阅