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

取得或設定與這個儲存格相關聯的工具提示文字。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 所使用的 Unmanaged 資源,並選擇性地釋放 Managed 資源。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)

擷取儲存格的已格式化的值,以複製到 ClipboardRetrieves 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 的淺層複本 (Shallow Copy)。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.

適用於

另請參閱