DataGridViewComboBoxCell DataGridViewComboBoxCell DataGridViewComboBoxCell DataGridViewComboBoxCell Class

定义

显示 DataGridView 控件中的组合框。Displays a combo box in a DataGridView control.

public ref class DataGridViewComboBoxCell : System::Windows::Forms::DataGridViewCell
public class DataGridViewComboBoxCell : System.Windows.Forms.DataGridViewCell
type DataGridViewComboBoxCell = class
    inherit DataGridViewCell
Public Class DataGridViewComboBoxCell
Inherits DataGridViewCell
继承

示例

下面的代码示例演示DataGridViewComboBoxColumn类,该协议使用DataGridViewComboBoxCell类。The following code example demonstrates the DataGridViewComboBoxColumn class, which makes use of the DataGridViewComboBoxCell class. 可以设置的单元格DataSourceValueMember,和DisplayMember中相应的列属性设置在此示例中的相同方式的属性。You can set the cell DataSource, ValueMember, and DisplayMember properties in the same way that the corresponding column properties are set in this example. 此示例摘自一个更大的示例中提供DataGridViewComboBoxColumn类概述主题。This example is part of a larger example available in the DataGridViewComboBoxColumn class overview topic.

private:
    DataGridViewComboBoxColumn^ CreateComboBoxColumn()
    {
        DataGridViewComboBoxColumn^ column =
            gcnew DataGridViewComboBoxColumn();
        {
            column->DataPropertyName = ColumnName::TitleOfCourtesy.ToString();
            column->HeaderText = ColumnName::TitleOfCourtesy.ToString();
            column->DropDownWidth = 160;
            column->Width = 90;
            column->MaxDropDownItems = 3;
            column->FlatStyle = FlatStyle::Flat;
        }
        return column;
    }

private:
    void SetAlternateChoicesUsingDataSource(DataGridViewComboBoxColumn^ comboboxColumn)
    {
        {
            comboboxColumn->DataSource = RetrieveAlternativeTitles();
            comboboxColumn->ValueMember = ColumnName::TitleOfCourtesy.ToString();
            comboboxColumn->DisplayMember = comboboxColumn->ValueMember;
        }
    }

private:
    DataTable^ RetrieveAlternativeTitles()
    {
        return Populate("SELECT distinct TitleOfCourtesy FROM Employees");
    }

    String^ connectionString;

private:
    DataTable^ Populate(String^ sqlCommand)
    {
        SqlConnection^ northwindConnection = gcnew SqlConnection(connectionString);
        northwindConnection->Open();

        SqlCommand^ command = gcnew SqlCommand(sqlCommand, northwindConnection);
        SqlDataAdapter^ adapter = gcnew SqlDataAdapter();
        adapter->SelectCommand = command;

        DataTable^ table = gcnew DataTable();
        adapter->Fill(table);

        return table;
    }

	// Using an enum provides some abstraction between column index
    // and column name along with compile time checking, and gives
    // a handy place to store the column names.
    enum class ColumnName
    {
        EmployeeID,
        LastName,
        FirstName,
        Title,
        TitleOfCourtesy,
        BirthDate,
        HireDate,
        Address,
        City,
        Region,
        PostalCode,
        Country,
        HomePhone,
        Extension,
        Photo,
        Notes,
        ReportsTo,
        PhotoPath,
        OutOfOffice
    };
private DataGridViewComboBoxColumn CreateComboBoxColumn()
{
    DataGridViewComboBoxColumn column =
        new DataGridViewComboBoxColumn();
    {
        column.DataPropertyName = ColumnName.TitleOfCourtesy.ToString();
        column.HeaderText = ColumnName.TitleOfCourtesy.ToString();
        column.DropDownWidth = 160;
        column.Width = 90;
        column.MaxDropDownItems = 3;
        column.FlatStyle = FlatStyle.Flat;
    }
    return column;
}

private void SetAlternateChoicesUsingDataSource(DataGridViewComboBoxColumn comboboxColumn)
{
    {
        comboboxColumn.DataSource = RetrieveAlternativeTitles();
        comboboxColumn.ValueMember = ColumnName.TitleOfCourtesy.ToString();
        comboboxColumn.DisplayMember = comboboxColumn.ValueMember;
    }
}

private DataTable RetrieveAlternativeTitles()
{
    return Populate("SELECT distinct TitleOfCourtesy FROM Employees");
}

string connectionString =
    "Integrated Security=SSPI;Persist Security Info=False;" +
    "Initial Catalog=Northwind;Data Source=localhost";

private DataTable Populate(string sqlCommand)
{
    SqlConnection northwindConnection = new SqlConnection(connectionString);
    northwindConnection.Open();

    SqlCommand command = new SqlCommand(sqlCommand, northwindConnection);
    SqlDataAdapter adapter = new SqlDataAdapter();
    adapter.SelectCommand = command;

    DataTable table = new DataTable();
    table.Locale = System.Globalization.CultureInfo.InvariantCulture;
    adapter.Fill(table);

    return table;
}

// Using an enum provides some abstraction between column index
// and column name along with compile time checking, and gives
// a handy place to store the column names.
enum ColumnName
{
    EmployeeId,
    LastName,
    FirstName,
    Title,
    TitleOfCourtesy,
    BirthDate,
    HireDate,
    Address,
    City,
    Region,
    PostalCode,
    Country,
    HomePhone,
    Extension,
    Photo,
    Notes,
    ReportsTo,
    PhotoPath,
    OutOfOffice
};
Private Function CreateComboBoxColumn() _
    As DataGridViewComboBoxColumn
    Dim column As New DataGridViewComboBoxColumn()

    With column
        .DataPropertyName = ColumnName.TitleOfCourtesy.ToString()
        .HeaderText = ColumnName.TitleOfCourtesy.ToString()
        .DropDownWidth = 160
        .Width = 90
        .MaxDropDownItems = 3
        .FlatStyle = FlatStyle.Flat
    End With
    Return column
End Function

Private Sub SetAlternateChoicesUsingDataSource( _
    ByVal comboboxColumn As DataGridViewComboBoxColumn)
    With comboboxColumn
        .DataSource = RetrieveAlternativeTitles()
        .ValueMember = ColumnName.TitleOfCourtesy.ToString()
        .DisplayMember = .ValueMember
    End With
End Sub

Private Function RetrieveAlternativeTitles() As DataTable
    Return Populate( _
        "SELECT distinct TitleOfCourtesy FROM Employees")
End Function

Private connectionString As String = _
        "Integrated Security=SSPI;Persist Security Info=False;" _
        & "Initial Catalog=Northwind;Data Source=localhost"

Private Function Populate(ByVal sqlCommand As String) As DataTable
    Dim northwindConnection As New SqlConnection(connectionString)
    northwindConnection.Open()

    Dim command As New SqlCommand(sqlCommand, _
        northwindConnection)
    Dim adapter As New SqlDataAdapter()
    adapter.SelectCommand = command
    Dim table As New DataTable()
    table.Locale = System.Globalization.CultureInfo.InvariantCulture
    adapter.Fill(table)

    Return table
End Function

' Using an enum provides some abstraction between column index
' and column name along with compile time checking, and gives
' a handy place to store the column names.
Enum ColumnName
    EmployeeId
    LastName
    FirstName
    Title
    TitleOfCourtesy
    BirthDate
    HireDate
    Address
    City
    Region
    PostalCode
    Country
    HomePhone
    Extension
    Photo
    Notes
    ReportsTo
    PhotoPath
    OutOfOffice
End Enum

注解

DataGridViewComboBoxCell类是种特殊的类型的DataGridViewCell用于显示组合框控件,这是与列表中选择字段结合使用的编辑字段。The DataGridViewComboBoxCell class is a specialized type of DataGridViewCell used to display a combo box control, which is an editing field combined with a list selection field. 当前所选DataGridViewComboBoxCell主机DataGridViewComboBoxEditingControl中的用户可以更改单元格的值,假定单元格ReadOnly属性设置为falseThe currently selected DataGridViewComboBoxCell hosts a DataGridViewComboBoxEditingControl in which the user can change the cell's value, assuming the cell's ReadOnly property is set to false.

与不同ComboBox控件,DataGridViewComboBoxCell不具有SelectedIndexSelectedValue属性。Unlike the ComboBox control, the DataGridViewComboBoxCell does not have SelectedIndex and SelectedValue properties. 相反,从下拉列表中选择一个值设置的单元格Value属性。Instead, selecting a value from a drop-down list sets the cell Value property.

DataGridViewComboBoxColumn列类型专用于保存此类型的单元格。The DataGridViewComboBoxColumn is the column type specialized to hold cells of this type. 默认情况下DataGridViewComboBoxColumn.CellTemplate函数将初始化为一个新DataGridViewComboBoxCellBy default, the DataGridViewComboBoxColumn.CellTemplate is initialized to a new DataGridViewComboBoxCell. 若要在列内的单元格模式的现有后DataGridViewComboBoxCell,设置该列的CellTemplate属性设置为要用作一种模式的单元格。To pattern the cells within a column after an existing DataGridViewComboBoxCell, set the column's CellTemplate property to the cell to use as a pattern.

列的单元格相关的属性都是相似的属性的模板单元格的包装。The cell-related properties of the column are wrappers for the similarly-named properties of the template cell. 更改模板单元格的属性值将只影响单元格基于模板在更改后添加。Changing the property values of the template cell will affect only cells based on the template that are added after the change. 更改列的单元格相关属性值,但是,将更新模板单元格和列中的所有其他单元格,如有必要刷新列显示。Changing the cell-related property values of the column, however, will update the template cell and all other cells in the column, and refresh the column display if necessary.

通常会使用DataGridViewComboBoxColumn类型,除非你想要替代特定单元的列值。You will typically work with the DataGridViewComboBoxColumn type unless you want to override column values for specific cells. 中介绍的指导原则DataGridViewComboBoxColumn类用于填充下拉列表的概述主题适用于单元格和列的实例。The guidelines described in the DataGridViewComboBoxColumn class overview topic for populating the drop-down list applies to both cell and column instances.

继承者说明

派生自DataGridViewComboBoxCell并将新属性添加到派生类,请确保重写Clone()方法以在克隆操作过程中复制新属性。When you derive from DataGridViewComboBoxCell and add new properties to the derived class, be sure to override the Clone() method to copy the new properties during cloning operations. 此外应调用基类的Clone()方法,以便基类的属性复制到新的单元格。You should also call the base class's Clone() method so that the properties of the base class are copied to the new cell.

构造函数

DataGridViewComboBoxCell() DataGridViewComboBoxCell() DataGridViewComboBoxCell() DataGridViewComboBoxCell()

初始化 DataGridViewComboBoxCell 类的新实例。Initializes a new instance of the DataGridViewComboBoxCell class.

属性

AccessibilityObject AccessibilityObject AccessibilityObject AccessibilityObject

获取分配给 DataGridViewCell.DataGridViewCellAccessibleObjectDataGridViewCellGets the DataGridViewCell.DataGridViewCellAccessibleObject assigned to the DataGridViewCell.

(Inherited from DataGridViewCell)
AutoComplete AutoComplete AutoComplete AutoComplete

获取或设置一个值,该值指示单元格是否将单元格中输入的字符与下拉列表中的选项匹配。Gets or sets a value indicating whether the cell will match the characters being entered in the cell with a selection from the drop-down list.

ColumnIndex ColumnIndex ColumnIndex ColumnIndex

获取此单元格的列索引。Gets the column index for this cell.

(Inherited from DataGridViewCell)
ContentBounds ContentBounds ContentBounds ContentBounds

获取环绕单元格内容区域的边框。Gets the bounding rectangle that encloses the cell's content area.

(Inherited from DataGridViewCell)
ContextMenuStrip ContextMenuStrip ContextMenuStrip ContextMenuStrip

获取或设置与单元格关联的快捷菜单。Gets or sets the shortcut menu associated with the cell.

(Inherited from DataGridViewCell)
DataGridView DataGridView DataGridView DataGridView

获取与此元素关联的 DataGridView 控件。Gets the DataGridView control associated with this element.

(Inherited from DataGridViewElement)
DataSource DataSource DataSource DataSource

获取或设置数据源,其数据包含下拉列表中可能会显示的选项。Gets or sets the data source whose data contains the possible selections shown in the drop-down list.

DefaultNewRowValue DefaultNewRowValue DefaultNewRowValue DefaultNewRowValue

获取新记录所在行中单元格的默认值。Gets the default value for a cell in the row for new records.

(Inherited from DataGridViewCell)
Displayed Displayed Displayed Displayed

获取一个值,该值指示当前该单元格是否显示在屏幕上。Gets a value that indicates whether the cell is currently displayed on-screen.

(Inherited from DataGridViewCell)
DisplayMember DisplayMember DisplayMember DisplayMember

获取或设置一个字符串,该字符串指定要在何处收集将在下拉列表中显示的选项。Gets or sets a string that specifies where to gather selections to display in the drop-down list.

DisplayStyle DisplayStyle DisplayStyle DisplayStyle

获取或设置一个值,该值确定当组合框处于非编辑模式时它的显示方式。Gets or sets a value that determines how the combo box is displayed when it is not in edit mode.

DisplayStyleForCurrentCellOnly DisplayStyleForCurrentCellOnly DisplayStyleForCurrentCellOnly DisplayStyleForCurrentCellOnly

获取或设置一个值,该值指示 DisplayStyle 属性值是否仅适用于 DataGridView 控件中的当前单元格。Gets or sets a value indicating whether the DisplayStyle property value applies to the cell only when it is the current cell in the DataGridView control.

DropDownWidth DropDownWidth DropDownWidth DropDownWidth

获取或设置组合框下拉列表部分的宽度。Gets or sets the width of the of the drop-down list portion of a combo box.

EditedFormattedValue EditedFormattedValue EditedFormattedValue EditedFormattedValue

获取该单元格的当前格式化值,而不考虑该单元格是否处于编辑模式,也不论是否尚未提交此值。Gets the current, formatted value of the cell, regardless of whether the cell is in edit mode and the value has not been committed.

(Inherited from DataGridViewCell)
EditType EditType EditType EditType

获取单元格的寄宿编辑控件的类型。Gets the type of the cell's hosted editing control.

ErrorIconBounds ErrorIconBounds ErrorIconBounds ErrorIconBounds

获取单元格的错误图标的界限。Gets the bounds of the error icon for the cell.

(Inherited from DataGridViewCell)
ErrorText ErrorText ErrorText ErrorText

获取或设置描述与该单元格关联的错误条件的文本。Gets or sets the text describing an error condition associated with the cell.

(Inherited from DataGridViewCell)
FlatStyle FlatStyle FlatStyle FlatStyle

获取或设置单元格的平面样式外观。Gets or sets the flat style appearance of the cell.

FormattedValue FormattedValue FormattedValue FormattedValue

获取为显示进行格式化的单元格的值。Gets the value of the cell as formatted for display.

(Inherited from DataGridViewCell)
FormattedValueType FormattedValueType FormattedValueType FormattedValueType

获取与单元格关联的格式化值的类类型。Gets the class type of the formatted value associated with the cell.

Frozen Frozen Frozen Frozen

获取指示单元格是否已被冻结的值。Gets a value indicating whether the cell is frozen.

(Inherited from DataGridViewCell)
HasStyle HasStyle HasStyle HasStyle

获取指示是否已设置 Style 属性的值。Gets a value indicating whether the Style property has been set.

(Inherited from DataGridViewCell)
InheritedState InheritedState InheritedState InheritedState

获取该单元格从它的行和列的状态继承后的当前状态。Gets the current state of the cell as inherited from the state of its row and column.

(Inherited from DataGridViewCell)
InheritedStyle InheritedStyle InheritedStyle InheritedStyle

获取当前应用于单元格的样式。Gets the style currently applied to the cell.

(Inherited from DataGridViewCell)
IsInEditMode IsInEditMode IsInEditMode IsInEditMode

获取一个值,该值指示此单元格当前是否处于编辑状态。Gets a value indicating whether this cell is currently being edited.

(Inherited from DataGridViewCell)
Items Items Items Items

获取对象,这些对象表示下拉列表中显示的选项。Gets the objects that represent the selection displayed in the drop-down list.

MaxDropDownItems MaxDropDownItems MaxDropDownItems MaxDropDownItems

获取或设置下拉列表中显示的最大项数。Gets or sets the maximum number of items shown in the drop-down list.

OwningColumn OwningColumn OwningColumn OwningColumn

获取包含此单元格的列。Gets the column that contains this cell.

(Inherited from DataGridViewCell)
OwningRow OwningRow OwningRow OwningRow

获取包含此单元格的行。Gets the row that contains this cell.

(Inherited from DataGridViewCell)
PreferredSize PreferredSize PreferredSize PreferredSize

获取适合该单元格的矩形区域的大小(以像素为单位)。Gets the size, in pixels, of a rectangular area into which the cell can fit.

(Inherited from DataGridViewCell)
ReadOnly ReadOnly ReadOnly ReadOnly

获取或设置一个值,该值表示是否可以编辑该单元格的数据。Gets or sets a value indicating whether the cell's data can be edited.

(Inherited from DataGridViewCell)
Resizable Resizable Resizable Resizable

获取一个值,该值指示是否可以调整单元格的大小。Gets a value indicating whether the cell can be resized.

(Inherited from DataGridViewCell)
RowIndex RowIndex RowIndex RowIndex

获取单元格父行的索引。Gets the index of the cell's parent row.

(Inherited from DataGridViewCell)
Selected Selected Selected Selected

获取或设置一个值,该值指示是否已选定该单元格。Gets or sets a value indicating whether the cell has been selected.

(Inherited from DataGridViewCell)
Size Size Size Size

获取单元格的大小。Gets the size of the cell.

(Inherited from DataGridViewCell)
Sorted Sorted Sorted Sorted

获取或设置一个值,该值指示是否对组合框中的项进行了自动排序。Gets or sets a value indicating whether the items in the combo box are automatically sorted.

State State State State

获取元素的用户界面 (UI) 状态。Gets the user interface (UI) state of the element.

(Inherited from DataGridViewElement)
Style Style Style Style

获取或设置单元格的样式。Gets or sets the style for the cell.

(Inherited from DataGridViewCell)
Tag Tag Tag Tag

获取或设置包含有关单元格补充数据的对象。Gets or sets the object that contains supplemental data about the cell.

(Inherited from DataGridViewCell)
ToolTipText ToolTipText ToolTipText ToolTipText

获取或设置与此单元格关联的 ToolTip 文本。Gets or sets the ToolTip text associated with this cell.

(Inherited from DataGridViewCell)
Value Value Value Value

获取或设置与此单元格关联的值。Gets or sets the value associated with this cell.

(Inherited from DataGridViewCell)
ValueMember ValueMember ValueMember ValueMember

获取或设置一个字符串,指定要在何处收集下拉列表中使用的基础值。Gets or sets a string that specifies where to gather the underlying values used in the drop-down list.

ValueType ValueType ValueType ValueType

获取或设置单元格中值的数据类型。Gets or sets the data type of the values in the cell.

Visible Visible Visible Visible

获取一个值,该值指示单元格是否位于已隐藏的行或列中。Gets a value indicating whether the cell is in a row or column that has been hidden.

(Inherited from DataGridViewCell)

方法

AdjustCellBorderStyle(DataGridViewAdvancedBorderStyle, DataGridViewAdvancedBorderStyle, Boolean, Boolean, Boolean, Boolean) AdjustCellBorderStyle(DataGridViewAdvancedBorderStyle, DataGridViewAdvancedBorderStyle, Boolean, Boolean, Boolean, Boolean) AdjustCellBorderStyle(DataGridViewAdvancedBorderStyle, DataGridViewAdvancedBorderStyle, Boolean, Boolean, Boolean, Boolean) AdjustCellBorderStyle(DataGridViewAdvancedBorderStyle, DataGridViewAdvancedBorderStyle, Boolean, Boolean, Boolean, Boolean)

根据指定条件修改输入单元格的边框样式。Modifies the input cell border style according to the specified criteria.

(Inherited from DataGridViewCell)
BorderWidths(DataGridViewAdvancedBorderStyle) BorderWidths(DataGridViewAdvancedBorderStyle) BorderWidths(DataGridViewAdvancedBorderStyle) BorderWidths(DataGridViewAdvancedBorderStyle)

返回一个 Rectangle,它表示所有单元格的边距宽度。Returns a Rectangle that represents the widths of all the cell margins.

(Inherited from DataGridViewCell)
ClickUnsharesRow(DataGridViewCellEventArgs) ClickUnsharesRow(DataGridViewCellEventArgs) ClickUnsharesRow(DataGridViewCellEventArgs) ClickUnsharesRow(DataGridViewCellEventArgs)

指示在单击单元格时,是否对单元格所在的行取消共享。Indicates whether the cell's row will be unshared when the cell is clicked.

(Inherited from DataGridViewCell)
Clone() Clone() Clone() Clone()

创建此单元格的精确副本。Creates an exact copy of this cell.

ContentClickUnsharesRow(DataGridViewCellEventArgs) ContentClickUnsharesRow(DataGridViewCellEventArgs) ContentClickUnsharesRow(DataGridViewCellEventArgs) ContentClickUnsharesRow(DataGridViewCellEventArgs)

指示在单击单元格的内容时,是否对该单元格所在的行取消共享。Indicates whether the cell's row will be unshared when the cell's content is clicked.

(Inherited from DataGridViewCell)
ContentDoubleClickUnsharesRow(DataGridViewCellEventArgs) ContentDoubleClickUnsharesRow(DataGridViewCellEventArgs) ContentDoubleClickUnsharesRow(DataGridViewCellEventArgs) ContentDoubleClickUnsharesRow(DataGridViewCellEventArgs)

指示在双击单元格的内容时,是否对该单元格所在的行取消共享。Indicates whether the cell's row will be unshared when the cell's content is double-clicked.

(Inherited from DataGridViewCell)
CreateAccessibilityInstance() CreateAccessibilityInstance() CreateAccessibilityInstance() CreateAccessibilityInstance()

为此 DataGridViewComboBoxCell 实例创建新 AccessibleObjectCreates a new AccessibleObject for this DataGridViewComboBoxCell instance.

DetachEditingControl() DetachEditingControl() DetachEditingControl() DetachEditingControl()

DataGridView 中移除单元格的编辑控件。Removes the cell's editing control from the DataGridView.

Dispose() Dispose() Dispose() Dispose()

释放由 DataGridViewCell 使用的所有资源。Releases all resources used by the DataGridViewCell.

(Inherited from DataGridViewCell)
Dispose(Boolean) Dispose(Boolean) Dispose(Boolean) Dispose(Boolean)

释放由 DataGridViewCell 占用的非托管资源,还可以另外再释放托管资源。Releases the unmanaged resources used by the DataGridViewCell and optionally releases the managed resources.

(Inherited from DataGridViewCell)
DoubleClickUnsharesRow(DataGridViewCellEventArgs) DoubleClickUnsharesRow(DataGridViewCellEventArgs) DoubleClickUnsharesRow(DataGridViewCellEventArgs) DoubleClickUnsharesRow(DataGridViewCellEventArgs)

指示在双击单元格时,是否对该单元格所在的行取消共享。Indicates whether the cell's row will be unshared when the cell is double-clicked.

(Inherited from DataGridViewCell)
EnterUnsharesRow(Int32, Boolean) EnterUnsharesRow(Int32, Boolean) EnterUnsharesRow(Int32, Boolean) EnterUnsharesRow(Int32, Boolean)

指示在焦点移到某单元格时,是否对相应父行取消共享。Indicates whether the parent row will be unshared when the focus moves to the cell.

(Inherited from DataGridViewCell)
Equals(Object) Equals(Object) Equals(Object) Equals(Object)

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetClipboardContent(Int32, Boolean, Boolean, Boolean, Boolean, String) GetClipboardContent(Int32, Boolean, Boolean, Boolean, Boolean, String) GetClipboardContent(Int32, Boolean, Boolean, Boolean, Boolean, String) GetClipboardContent(Int32, Boolean, Boolean, Boolean, Boolean, String)

检索要复制到 Clipboard 的单元格的已设置格式的值。Retrieves the formatted value of the cell to copy to the Clipboard.

(Inherited from DataGridViewCell)
GetContentBounds(Graphics, DataGridViewCellStyle, Int32) GetContentBounds(Graphics, DataGridViewCellStyle, Int32) GetContentBounds(Graphics, DataGridViewCellStyle, Int32) GetContentBounds(Graphics, DataGridViewCellStyle, Int32)

返回围绕单元格内容区域的边框,该区域是使用指定的 Graphics 和单元格样式计算的。Returns the bounding rectangle that encloses the cell's content area, which is calculated using the specified Graphics and cell style.

GetContentBounds(Int32) GetContentBounds(Int32) GetContentBounds(Int32) GetContentBounds(Int32)

使用默认的 Graphics 和单元格当前应用的单元格样式,返回围绕单元格内容区域的边框。Returns the bounding rectangle that encloses the cell's content area using a default Graphics and cell style currently in effect for the cell.

(Inherited from DataGridViewCell)
GetEditedFormattedValue(Int32, DataGridViewDataErrorContexts) GetEditedFormattedValue(Int32, DataGridViewDataErrorContexts) GetEditedFormattedValue(Int32, DataGridViewDataErrorContexts) GetEditedFormattedValue(Int32, DataGridViewDataErrorContexts)

返回该单元格的当前格式化值,而不考虑该单元格是否处于编辑模式,也无论是否尚未提交此值。Returns the current, formatted value of the cell, regardless of whether the cell is in edit mode and the value has not been committed.

(Inherited from DataGridViewCell)
GetErrorIconBounds(Graphics, DataGridViewCellStyle, Int32) GetErrorIconBounds(Graphics, DataGridViewCellStyle, Int32) GetErrorIconBounds(Graphics, DataGridViewCellStyle, Int32) GetErrorIconBounds(Graphics, DataGridViewCellStyle, Int32)

如果显示了单元格的错误图标,则返回环绕该图标的边框。Returns the bounding rectangle that encloses the cell's error icon, if one is displayed.

GetErrorText(Int32) GetErrorText(Int32) GetErrorText(Int32) GetErrorText(Int32)

返回表示单元格错误的字符串。Returns a string that represents the error for the cell.

(Inherited from DataGridViewCell)
GetFormattedValue(Object, Int32, DataGridViewCellStyle, TypeConverter, TypeConverter, DataGridViewDataErrorContexts) GetFormattedValue(Object, Int32, DataGridViewCellStyle, TypeConverter, TypeConverter, DataGridViewDataErrorContexts) GetFormattedValue(Object, Int32, DataGridViewCellStyle, TypeConverter, TypeConverter, DataGridViewDataErrorContexts) GetFormattedValue(Object, Int32, DataGridViewCellStyle, TypeConverter, TypeConverter, DataGridViewDataErrorContexts)

获取单元格数据的格式化值。Gets the formatted value of the cell's data.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

作为默认哈希函数。Serves as the default hash function.

(Inherited from Object)
GetInheritedContextMenuStrip(Int32) GetInheritedContextMenuStrip(Int32) GetInheritedContextMenuStrip(Int32) GetInheritedContextMenuStrip(Int32)

获取当前单元格的继承快捷菜单。Gets the inherited shortcut menu for the current cell.

(Inherited from DataGridViewCell)
GetInheritedState(Int32) GetInheritedState(Int32) GetInheritedState(Int32) GetInheritedState(Int32)

返回一个值,该值指示此单元格从它的行和列的状态继承后的当前状态。Returns a value indicating the current state of the cell as inherited from the state of its row and column.

(Inherited from DataGridViewCell)
GetInheritedStyle(DataGridViewCellStyle, Int32, Boolean) GetInheritedStyle(DataGridViewCellStyle, Int32, Boolean) GetInheritedStyle(DataGridViewCellStyle, Int32, Boolean) GetInheritedStyle(DataGridViewCellStyle, Int32, Boolean)

获取应用于该单元格的样式。Gets the style applied to the cell.

(Inherited from DataGridViewCell)
GetPreferredSize(Graphics, DataGridViewCellStyle, Int32, Size) GetPreferredSize(Graphics, DataGridViewCellStyle, Int32, Size) GetPreferredSize(Graphics, DataGridViewCellStyle, Int32, Size) GetPreferredSize(Graphics, DataGridViewCellStyle, Int32, Size)

计算单元格的首选大小(以像素为单位)。Calculates the preferred size, in pixels, of the cell.

GetSize(Int32) GetSize(Int32) GetSize(Int32) GetSize(Int32)

获取单元格的大小。Gets the size of the cell.

(Inherited from DataGridViewCell)
GetType() GetType() GetType() GetType()

获取当前实例的 TypeGets the Type of the current instance.

(Inherited from Object)
GetValue(Int32) GetValue(Int32) GetValue(Int32) GetValue(Int32)

获取单元格的值。Gets the value of the cell.

(Inherited from DataGridViewCell)
InitializeEditingControl(Int32, Object, DataGridViewCellStyle) InitializeEditingControl(Int32, Object, DataGridViewCellStyle) InitializeEditingControl(Int32, Object, DataGridViewCellStyle) InitializeEditingControl(Int32, Object, DataGridViewCellStyle)

附加并初始化寄宿的编辑控件。Attaches and initializes the hosted editing control.

KeyDownUnsharesRow(KeyEventArgs, Int32) KeyDownUnsharesRow(KeyEventArgs, Int32) KeyDownUnsharesRow(KeyEventArgs, Int32) KeyDownUnsharesRow(KeyEventArgs, Int32)

指示在焦点位于单元格上,同时用户按任意键时,是否对父行取消共享。Indicates whether the parent row is unshared if the user presses a key while the focus is on the cell.

(Inherited from DataGridViewCell)
KeyEntersEditMode(KeyEventArgs) KeyEntersEditMode(KeyEventArgs) KeyEntersEditMode(KeyEventArgs) KeyEntersEditMode(KeyEventArgs)

确定是否应基于给定键启动编辑模式。Determines if edit mode should be started based on the given key.

KeyPressUnsharesRow(KeyPressEventArgs, Int32) KeyPressUnsharesRow(KeyPressEventArgs, Int32) KeyPressUnsharesRow(KeyPressEventArgs, Int32) KeyPressUnsharesRow(KeyPressEventArgs, Int32)

指示在焦点位于该行的单元格上并同时按任意键时,是否取消行的共享。Indicates whether a row will be unshared if a key is pressed while a cell in the row has focus.

(Inherited from DataGridViewCell)
KeyUpUnsharesRow(KeyEventArgs, Int32) KeyUpUnsharesRow(KeyEventArgs, Int32) KeyUpUnsharesRow(KeyEventArgs, Int32) KeyUpUnsharesRow(KeyEventArgs, Int32)

指示当焦点位于单元格上,同时用户释放某个键时,是否对父行取消共享。Indicates whether the parent row is unshared when the user releases a key while the focus is on the cell.

(Inherited from DataGridViewCell)
LeaveUnsharesRow(Int32, Boolean) LeaveUnsharesRow(Int32, Boolean) LeaveUnsharesRow(Int32, Boolean) LeaveUnsharesRow(Int32, Boolean)

指示在焦点离开某行的单元格时,是否对该行取消共享。Indicates whether a row will be unshared when the focus leaves a cell in the row.

(Inherited from DataGridViewCell)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(Inherited from Object)
MouseClickUnsharesRow(DataGridViewCellMouseEventArgs) MouseClickUnsharesRow(DataGridViewCellMouseEventArgs) MouseClickUnsharesRow(DataGridViewCellMouseEventArgs) MouseClickUnsharesRow(DataGridViewCellMouseEventArgs)

指示在鼠标指针位于某行的单元格上,同时用户单击鼠标按钮时,是否应对该行取消共享。Indicates whether a row will be unshared if the user clicks a mouse button while the pointer is on a cell in the row.

(Inherited from DataGridViewCell)
MouseDoubleClickUnsharesRow(DataGridViewCellMouseEventArgs) MouseDoubleClickUnsharesRow(DataGridViewCellMouseEventArgs) MouseDoubleClickUnsharesRow(DataGridViewCellMouseEventArgs) MouseDoubleClickUnsharesRow(DataGridViewCellMouseEventArgs)

指示当用户双击行中的单元格时,是否将对该行取消共享。Indicates whether a row will be unshared if the user double-clicks a cell in the row.

(Inherited from DataGridViewCell)
MouseDownUnsharesRow(DataGridViewCellMouseEventArgs) MouseDownUnsharesRow(DataGridViewCellMouseEventArgs) MouseDownUnsharesRow(DataGridViewCellMouseEventArgs) MouseDownUnsharesRow(DataGridViewCellMouseEventArgs)

指示在指针位于行中某个单元格上,同时用户按住鼠标按钮时,是否对该行取消共享。Indicates whether a row will be unshared when the user holds down a mouse button while the pointer is on a cell in the row.

(Inherited from DataGridViewCell)
MouseEnterUnsharesRow(Int32) MouseEnterUnsharesRow(Int32) MouseEnterUnsharesRow(Int32) MouseEnterUnsharesRow(Int32)

指示当鼠标指针移过行中某个单元格上时,该行是否取消共享状态。Indicates whether a row will be unshared when the mouse pointer moves over a cell in the row.

(Inherited from DataGridViewCell)
MouseLeaveUnsharesRow(Int32) MouseLeaveUnsharesRow(Int32) MouseLeaveUnsharesRow(Int32) MouseLeaveUnsharesRow(Int32)

指示当鼠标指针离开某行时,该行是否取消共享状态。Indicates whether a row will be unshared when the mouse pointer leaves the row.

(Inherited from DataGridViewCell)
MouseMoveUnsharesRow(DataGridViewCellMouseEventArgs) MouseMoveUnsharesRow(DataGridViewCellMouseEventArgs) MouseMoveUnsharesRow(DataGridViewCellMouseEventArgs) MouseMoveUnsharesRow(DataGridViewCellMouseEventArgs)

指示当鼠标指针移过行中某个单元格上时,该行是否取消共享状态。Indicates whether a row will be unshared when the mouse pointer moves over a cell in the row.

(Inherited from DataGridViewCell)
MouseUpUnsharesRow(DataGridViewCellMouseEventArgs) MouseUpUnsharesRow(DataGridViewCellMouseEventArgs) MouseUpUnsharesRow(DataGridViewCellMouseEventArgs) MouseUpUnsharesRow(DataGridViewCellMouseEventArgs)

指示在鼠标指针位于行中某个单元格上,同时用户释放鼠标按钮时,是否对该行取消共享。Indicates whether a row will be unshared when the user releases a mouse button while the pointer is on a cell in the row.

(Inherited from DataGridViewCell)
OnClick(DataGridViewCellEventArgs) OnClick(DataGridViewCellEventArgs) OnClick(DataGridViewCellEventArgs) OnClick(DataGridViewCellEventArgs)

在单击单元格时进行调用。Called when the cell is clicked.

(Inherited from DataGridViewCell)
OnContentClick(DataGridViewCellEventArgs) OnContentClick(DataGridViewCellEventArgs) OnContentClick(DataGridViewCellEventArgs) OnContentClick(DataGridViewCellEventArgs)

在单击单元格的内容时进行调用。Called when the cell's contents are clicked.

(Inherited from DataGridViewCell)
OnContentDoubleClick(DataGridViewCellEventArgs) OnContentDoubleClick(DataGridViewCellEventArgs) OnContentDoubleClick(DataGridViewCellEventArgs) OnContentDoubleClick(DataGridViewCellEventArgs)

在双击单元格的内容时进行调用。Called when the cell's contents are double-clicked.

(Inherited from DataGridViewCell)
OnDataGridViewChanged() OnDataGridViewChanged() OnDataGridViewChanged() OnDataGridViewChanged()

在单元格的 DataGridView 属性更改时调用。Called when the DataGridView property of the cell changes.

OnDoubleClick(DataGridViewCellEventArgs) OnDoubleClick(DataGridViewCellEventArgs) OnDoubleClick(DataGridViewCellEventArgs) OnDoubleClick(DataGridViewCellEventArgs)

在双击单元格时进行调用。Called when the cell is double-clicked.

(Inherited from DataGridViewCell)
OnEnter(Int32, Boolean) OnEnter(Int32, Boolean) OnEnter(Int32, Boolean) OnEnter(Int32, Boolean)

在焦点移动到单元格时进行调用。Called when the focus moves to a cell.

OnKeyDown(KeyEventArgs, Int32) OnKeyDown(KeyEventArgs, Int32) OnKeyDown(KeyEventArgs, Int32) OnKeyDown(KeyEventArgs, Int32)

在焦点位于单元格上并同时按下字符键时进行调用。Called when a character key is pressed while the focus is on a cell.

(Inherited from DataGridViewCell)
OnKeyPress(KeyPressEventArgs, Int32) OnKeyPress(KeyPressEventArgs, Int32) OnKeyPress(KeyPressEventArgs, Int32) OnKeyPress(KeyPressEventArgs, Int32)

在焦点位于单元格上并同时按任意键时进行调用。Called when a key is pressed while the focus is on a cell.

(Inherited from DataGridViewCell)
OnKeyUp(KeyEventArgs, Int32) OnKeyUp(KeyEventArgs, Int32) OnKeyUp(KeyEventArgs, Int32) OnKeyUp(KeyEventArgs, Int32)

在焦点位于单元格上并同时释放字符键时进行调用。Called when a character key is released while the focus is on a cell.

(Inherited from DataGridViewCell)
OnLeave(Int32, Boolean) OnLeave(Int32, Boolean) OnLeave(Int32, Boolean) OnLeave(Int32, Boolean)

当焦点从单元格上移开时调用。Called when the focus moves from a cell.

OnMouseClick(DataGridViewCellMouseEventArgs) OnMouseClick(DataGridViewCellMouseEventArgs) OnMouseClick(DataGridViewCellMouseEventArgs) OnMouseClick(DataGridViewCellMouseEventArgs)

在指针位于单元格上且用户同时单击鼠标按钮时进行调用。Called when the user clicks a mouse button while the pointer is on a cell.

OnMouseDoubleClick(DataGridViewCellMouseEventArgs) OnMouseDoubleClick(DataGridViewCellMouseEventArgs) OnMouseDoubleClick(DataGridViewCellMouseEventArgs) OnMouseDoubleClick(DataGridViewCellMouseEventArgs)

在指针位于单元格上,同时用户双击鼠标按钮时进行调用。Called when the user double-clicks a mouse button while the pointer is on a cell.

(Inherited from DataGridViewCell)
OnMouseDown(DataGridViewCellMouseEventArgs) OnMouseDown(DataGridViewCellMouseEventArgs) OnMouseDown(DataGridViewCellMouseEventArgs) OnMouseDown(DataGridViewCellMouseEventArgs)

在指针位于单元格上,同时用户按住鼠标按钮时进行调用。Called when the user holds down a mouse button while the pointer is on a cell.

(Inherited from DataGridViewCell)
OnMouseEnter(Int32) OnMouseEnter(Int32) OnMouseEnter(Int32) OnMouseEnter(Int32)

当鼠标指针移到单元格上时调用。Called when the mouse pointer moves over a cell.

OnMouseLeave(Int32) OnMouseLeave(Int32) OnMouseLeave(Int32) OnMouseLeave(Int32)

在鼠标指针离开单元格时调用。Called when the mouse pointer leaves the cell.

OnMouseMove(DataGridViewCellMouseEventArgs) OnMouseMove(DataGridViewCellMouseEventArgs) OnMouseMove(DataGridViewCellMouseEventArgs) OnMouseMove(DataGridViewCellMouseEventArgs)

当鼠标指针在单元格内移动时调用。Called when the mouse pointer moves within a cell.

OnMouseUp(DataGridViewCellMouseEventArgs) OnMouseUp(DataGridViewCellMouseEventArgs) OnMouseUp(DataGridViewCellMouseEventArgs) OnMouseUp(DataGridViewCellMouseEventArgs)

在指针位于单元格上,同时用户释放鼠标按钮时进行调用。Called when the user releases a mouse button while the pointer is on a cell.

(Inherited from DataGridViewCell)
Paint(Graphics, Rectangle, Rectangle, Int32, DataGridViewElementStates, Object, Object, String, DataGridViewCellStyle, DataGridViewAdvancedBorderStyle, DataGridViewPaintParts) Paint(Graphics, Rectangle, Rectangle, Int32, DataGridViewElementStates, Object, Object, String, DataGridViewCellStyle, DataGridViewAdvancedBorderStyle, DataGridViewPaintParts) Paint(Graphics, Rectangle, Rectangle, Int32, DataGridViewElementStates, Object, Object, String, DataGridViewCellStyle, DataGridViewAdvancedBorderStyle, DataGridViewPaintParts) Paint(Graphics, Rectangle, Rectangle, Int32, DataGridViewElementStates, Object, Object, String, DataGridViewCellStyle, DataGridViewAdvancedBorderStyle, DataGridViewPaintParts)

绘制当前的 DataGridViewComboBoxCellPaints the current DataGridViewComboBoxCell.

PaintBorder(Graphics, Rectangle, Rectangle, DataGridViewCellStyle, DataGridViewAdvancedBorderStyle) PaintBorder(Graphics, Rectangle, Rectangle, DataGridViewCellStyle, DataGridViewAdvancedBorderStyle) PaintBorder(Graphics, Rectangle, Rectangle, DataGridViewCellStyle, DataGridViewAdvancedBorderStyle) PaintBorder(Graphics, Rectangle, Rectangle, DataGridViewCellStyle, DataGridViewAdvancedBorderStyle)

绘制当前 DataGridViewCell 的边框。Paints the border of the current DataGridViewCell.

(Inherited from DataGridViewCell)
PaintErrorIcon(Graphics, Rectangle, Rectangle, String) PaintErrorIcon(Graphics, Rectangle, Rectangle, String) PaintErrorIcon(Graphics, Rectangle, Rectangle, String) PaintErrorIcon(Graphics, Rectangle, Rectangle, String)

绘制当前 DataGridViewCell 的错误图标。Paints the error icon of the current DataGridViewCell.

(Inherited from DataGridViewCell)
ParseFormattedValue(Object, DataGridViewCellStyle, TypeConverter, TypeConverter) ParseFormattedValue(Object, DataGridViewCellStyle, TypeConverter, TypeConverter) ParseFormattedValue(Object, DataGridViewCellStyle, TypeConverter, TypeConverter) ParseFormattedValue(Object, DataGridViewCellStyle, TypeConverter, TypeConverter)

将为便于显示而进行了格式设置的值转换为实际的单元格值。Converts a value formatted for display to an actual cell value.

PositionEditingControl(Boolean, Boolean, Rectangle, Rectangle, DataGridViewCellStyle, Boolean, Boolean, Boolean, Boolean) PositionEditingControl(Boolean, Boolean, Rectangle, Rectangle, DataGridViewCellStyle, Boolean, Boolean, Boolean, Boolean) PositionEditingControl(Boolean, Boolean, Rectangle, Rectangle, DataGridViewCellStyle, Boolean, Boolean, Boolean, Boolean) PositionEditingControl(Boolean, Boolean, Rectangle, Rectangle, DataGridViewCellStyle, Boolean, Boolean, Boolean, Boolean)

设置由 DataGridView 控件中的单元格承载的编辑控件的位置和大小。Sets the location and size of the editing control hosted by a cell in the DataGridView control.

(Inherited from DataGridViewCell)
PositionEditingPanel(Rectangle, Rectangle, DataGridViewCellStyle, Boolean, Boolean, Boolean, Boolean) PositionEditingPanel(Rectangle, Rectangle, DataGridViewCellStyle, Boolean, Boolean, Boolean, Boolean) PositionEditingPanel(Rectangle, Rectangle, DataGridViewCellStyle, Boolean, Boolean, Boolean, Boolean) PositionEditingPanel(Rectangle, Rectangle, DataGridViewCellStyle, Boolean, Boolean, Boolean, Boolean)

设置单元格承载的编辑面板的位置和大小,并返回编辑面板内编辑控件的正常界限。Sets the location and size of the editing panel hosted by the cell, and returns the normal bounds of the editing control within the editing panel.

(Inherited from DataGridViewCell)
RaiseCellClick(DataGridViewCellEventArgs) RaiseCellClick(DataGridViewCellEventArgs) RaiseCellClick(DataGridViewCellEventArgs) RaiseCellClick(DataGridViewCellEventArgs)

引发 CellClick 事件。Raises the CellClick event.

(Inherited from DataGridViewElement)
RaiseCellContentClick(DataGridViewCellEventArgs) RaiseCellContentClick(DataGridViewCellEventArgs) RaiseCellContentClick(DataGridViewCellEventArgs) RaiseCellContentClick(DataGridViewCellEventArgs)

引发 CellContentClick 事件。Raises the CellContentClick event.

(Inherited from DataGridViewElement)
RaiseCellContentDoubleClick(DataGridViewCellEventArgs) RaiseCellContentDoubleClick(DataGridViewCellEventArgs) RaiseCellContentDoubleClick(DataGridViewCellEventArgs) RaiseCellContentDoubleClick(DataGridViewCellEventArgs)

引发 CellContentDoubleClick 事件。Raises the CellContentDoubleClick event.

(Inherited from DataGridViewElement)
RaiseCellValueChanged(DataGridViewCellEventArgs) RaiseCellValueChanged(DataGridViewCellEventArgs) RaiseCellValueChanged(DataGridViewCellEventArgs) RaiseCellValueChanged(DataGridViewCellEventArgs)

引发 CellValueChanged 事件。Raises the CellValueChanged event.

(Inherited from DataGridViewElement)
RaiseDataError(DataGridViewDataErrorEventArgs) RaiseDataError(DataGridViewDataErrorEventArgs) RaiseDataError(DataGridViewDataErrorEventArgs) RaiseDataError(DataGridViewDataErrorEventArgs)

引发 DataError 事件。Raises the DataError event.

(Inherited from DataGridViewElement)
RaiseMouseWheel(MouseEventArgs) RaiseMouseWheel(MouseEventArgs) RaiseMouseWheel(MouseEventArgs) RaiseMouseWheel(MouseEventArgs)

引发 MouseWheel 事件。Raises the MouseWheel event.

(Inherited from DataGridViewElement)
SetValue(Int32, Object) SetValue(Int32, Object) SetValue(Int32, Object) SetValue(Int32, Object)

设置单元格的值。Sets the value of the cell.

(Inherited from DataGridViewCell)
ToString() ToString() ToString() ToString()

返回描述当前对象的字符串。Returns a string that describes the current object.

适用于

另请参阅