DataGridViewButtonCell 類別

定義

顯示用於 DataGridView 控制項,類似於按鈕的使用者介面 (UI)。Displays a button-like user interface (UI) for use in a DataGridView control.

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

範例

下列程式碼範例示範如何使用在DataGridViewButtonColumn特定資料列上執行動作。The following code example demonstrates how to use a DataGridViewButtonColumn to perform actions on particular rows. 處理個別DataGridViewButtonCell物件時, 您可以使用類似的程式碼。You can use similar code when working with individual DataGridViewButtonCell objects. 在此範例中, DataGridView.CellClick事件處理常式會先決定是否在按鈕資料格上按一下, 然後抓取與資料列相關聯的商務物件。In this example, a DataGridView.CellClick event handler first determines whether a click is on a button cell, then retrieves a business object associated with the row. 這個範例是中所提供之較大範例的一部分。存取 Windows Forms DataGridViewComboBoxCell 下拉式清單中的物件。This example is part of a larger example available in How to: Access Objects in a Windows Forms DataGridViewComboBoxCell Drop-Down List.

public class Form1 : Form
{
    private List<Employee> employees = new List<Employee>();
    private List<Task> tasks = new List<Task>();
    private Button reportButton = new Button();
    private DataGridView dataGridView1 = new DataGridView();

    [STAThread]
    public static void Main()
    {
        Application.Run(new Form1());
    }

    public Form1()
    {
        dataGridView1.Dock = DockStyle.Fill;
        dataGridView1.AutoSizeColumnsMode = 
            DataGridViewAutoSizeColumnsMode.AllCells;
        reportButton.Text = "Generate Report";
        reportButton.Dock = DockStyle.Top;
        reportButton.Click += new EventHandler(reportButton_Click);

        Controls.Add(dataGridView1);
        Controls.Add(reportButton);
        Load += new EventHandler(Form1_Load);
        Text = "DataGridViewComboBoxColumn Demo";
    }

    // Initializes the data source and populates the DataGridView control.
    private void Form1_Load(object sender, EventArgs e)
    {
        PopulateLists();
        dataGridView1.AutoGenerateColumns = false;
        dataGridView1.DataSource = tasks;
        AddColumns();
    }

    // Populates the employees and tasks lists. 
    private void PopulateLists()
    {
        employees.Add(new Employee("Harry"));
        employees.Add(new Employee("Sally"));
        employees.Add(new Employee("Roy"));
        employees.Add(new Employee("Pris"));
        tasks.Add(new Task(1, employees[1]));
        tasks.Add(new Task(2));
        tasks.Add(new Task(3, employees[2]));
        tasks.Add(new Task(4));
    }

    // Configures columns for the DataGridView control.
    private void AddColumns()
    {
        DataGridViewTextBoxColumn idColumn = 
            new DataGridViewTextBoxColumn();
        idColumn.Name = "Task";
        idColumn.DataPropertyName = "Id";
        idColumn.ReadOnly = true;

        DataGridViewComboBoxColumn assignedToColumn = 
            new DataGridViewComboBoxColumn();

        // Populate the combo box drop-down list with Employee objects. 
        foreach (Employee e in employees) assignedToColumn.Items.Add(e);

        // Add "unassigned" to the drop-down list and display it for 
        // empty AssignedTo values or when the user presses CTRL+0. 
        assignedToColumn.Items.Add("unassigned");
        assignedToColumn.DefaultCellStyle.NullValue = "unassigned";

        assignedToColumn.Name = "Assigned To";
        assignedToColumn.DataPropertyName = "AssignedTo";
        assignedToColumn.AutoComplete = true;
        assignedToColumn.DisplayMember = "Name";
        assignedToColumn.ValueMember = "Self";

        // Add a button column. 
        DataGridViewButtonColumn buttonColumn = 
            new DataGridViewButtonColumn();
        buttonColumn.HeaderText = "";
        buttonColumn.Name = "Status Request";
        buttonColumn.Text = "Request Status";
        buttonColumn.UseColumnTextForButtonValue = true;

        dataGridView1.Columns.Add(idColumn);
        dataGridView1.Columns.Add(assignedToColumn);
        dataGridView1.Columns.Add(buttonColumn);

        // Add a CellClick handler to handle clicks in the button column.
        dataGridView1.CellClick +=
            new DataGridViewCellEventHandler(dataGridView1_CellClick);
    }

    // Reports on task assignments. 
    private void reportButton_Click(object sender, EventArgs e)
    {
        StringBuilder report = new StringBuilder();
        foreach (Task t in tasks)
        {
            String assignment = 
                t.AssignedTo == null ? 
                "unassigned" : "assigned to " + t.AssignedTo.Name;
            report.AppendFormat("Task {0} is {1}.", t.Id, assignment);
            report.Append(Environment.NewLine);
        }
        MessageBox.Show(report.ToString(), "Task Assignments");
    }

    // Calls the Employee.RequestStatus method.
    void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
    {
        // Ignore clicks that are not on button cells. 
        if (e.RowIndex < 0 || e.ColumnIndex !=
            dataGridView1.Columns["Status Request"].Index) return;

        // Retrieve the task ID.
        Int32 taskID = (Int32)dataGridView1[0, e.RowIndex].Value;

        // Retrieve the Employee object from the "Assigned To" cell.
        Employee assignedTo = dataGridView1.Rows[e.RowIndex]
            .Cells["Assigned To"].Value as Employee;

        // Request status through the Employee object if present. 
        if (assignedTo != null)
        {
            assignedTo.RequestStatus(taskID);
        }
        else
        {
            MessageBox.Show(String.Format(
                "Task {0} is unassigned.", taskID), "Status Request");
        }
    }

}
Public Class Form1
    Inherits Form

    Private employees As New List(Of Employee)
    Private tasks As New List(Of Task)
    Private WithEvents reportButton As New Button
    Private WithEvents dataGridView1 As New DataGridView

    <STAThread()> _
    Public Sub Main()
        Application.Run(New Form1)
    End Sub

    Sub New()
        dataGridView1.Dock = DockStyle.Fill
        dataGridView1.AutoSizeColumnsMode = _
            DataGridViewAutoSizeColumnsMode.AllCells
        reportButton.Text = "Generate Report"
        reportButton.Dock = DockStyle.Top

        Controls.Add(dataGridView1)
        Controls.Add(reportButton)
        Text = "DataGridViewComboBoxColumn Demo"
    End Sub

    ' Initializes the data source and populates the DataGridView control.
    Private Sub Form1_Load(ByVal sender As Object, _
        ByVal e As EventArgs) Handles Me.Load

        PopulateLists()
        dataGridView1.AutoGenerateColumns = False
        dataGridView1.DataSource = tasks
        AddColumns()

    End Sub

    ' Populates the employees and tasks lists. 
    Private Sub PopulateLists()
        employees.Add(New Employee("Harry"))
        employees.Add(New Employee("Sally"))
        employees.Add(New Employee("Roy"))
        employees.Add(New Employee("Pris"))
        tasks.Add(New Task(1, employees(1)))
        tasks.Add(New Task(2))
        tasks.Add(New Task(3, employees(2)))
        tasks.Add(New Task(4))
    End Sub

    ' Configures columns for the DataGridView control.
    Private Sub AddColumns()

        Dim idColumn As New DataGridViewTextBoxColumn()
        idColumn.Name = "Task"
        idColumn.DataPropertyName = "Id"
        idColumn.ReadOnly = True

        Dim assignedToColumn As New DataGridViewComboBoxColumn()

        ' Populate the combo box drop-down list with Employee objects. 
        For Each e As Employee In employees
            assignedToColumn.Items.Add(e)
        Next

        ' Add "unassigned" to the drop-down list and display it for 
        ' empty AssignedTo values or when the user presses CTRL+0. 
        assignedToColumn.Items.Add("unassigned")
        assignedToColumn.DefaultCellStyle.NullValue = "unassigned"

        assignedToColumn.Name = "Assigned To"
        assignedToColumn.DataPropertyName = "AssignedTo"
        assignedToColumn.AutoComplete = True
        assignedToColumn.DisplayMember = "Name"
        assignedToColumn.ValueMember = "Self"

        ' Add a button column. 
        Dim buttonColumn As New DataGridViewButtonColumn()
        buttonColumn.HeaderText = ""
        buttonColumn.Name = "Status Request"
        buttonColumn.Text = "Request Status"
        buttonColumn.UseColumnTextForButtonValue = True

        dataGridView1.Columns.Add(idColumn)
        dataGridView1.Columns.Add(assignedToColumn)
        dataGridView1.Columns.Add(buttonColumn)

    End Sub

    ' Reports on task assignments. 
    Private Sub reportButton_Click(ByVal sender As Object, _
        ByVal e As EventArgs) Handles reportButton.Click

        Dim report As New StringBuilder()
        For Each t As Task In tasks
            Dim assignment As String
            If t.AssignedTo Is Nothing Then
                assignment = "unassigned"
            Else
                assignment = "assigned to " + t.AssignedTo.Name
            End If
            report.AppendFormat("Task {0} is {1}.", t.Id, assignment)
            report.Append(Environment.NewLine)
        Next
        MessageBox.Show(report.ToString(), "Task Assignments")

    End Sub

    ' Calls the Employee.RequestStatus method.
    Private Sub dataGridView1_CellClick(ByVal sender As Object, _
        ByVal e As DataGridViewCellEventArgs) _
        Handles dataGridView1.CellClick

        ' Ignore clicks that are not on button cells. 
        If e.RowIndex < 0 OrElse Not e.ColumnIndex = _
            dataGridView1.Columns("Status Request").Index Then Return

        ' Retrieve the task ID.
        Dim taskID As Int32 = CInt(dataGridView1(0, e.RowIndex).Value)

        ' Retrieve the Employee object from the "Assigned To" cell.
        Dim assignedTo As Employee = TryCast(dataGridView1.Rows(e.RowIndex) _
            .Cells("Assigned To").Value, Employee)

        ' Request status through the Employee object if present. 
        If assignedTo IsNot Nothing Then
            assignedTo.RequestStatus(taskID)
        Else
            MessageBox.Show(String.Format( _
                "Task {0} is unassigned.", taskID), "Status Request")
        End If

    End Sub

End Class

備註

類別是DataGridViewCell用來顯示類似按鈕 UI 的特殊類型。 DataGridViewButtonCellThe DataGridViewButtonCell class is a specialized type of DataGridViewCell used to display a button-like UI.

DataGridViewButtonColumn這是用來保存此類型之儲存格的資料行類型。DataGridViewButtonColumn is the column type specialized to hold cells of this type. 根據預設, DataGridViewButtonColumn.CellTemplate會初始化為新DataGridViewButtonCell的。By default, the DataGridViewButtonColumn.CellTemplate is initialized to a new DataGridViewButtonCell. 若要在現有DataGridViewButtonCell的之後建立資料行中的資料格模式, 請將資料行的CellTemplate屬性設定為要當做模式使用的資料格。To pattern the cells within a column after an existing DataGridViewButtonCell, set the column's CellTemplate property to the cell to use as a pattern.

若要回應使用者按鈕的DataGridView.CellClick點擊, 請處理或DataGridView.CellContentClick事件。To respond to user button clicks, handle the DataGridView.CellClick or DataGridView.CellContentClick event. 在事件處理常式中, 您可以使用DataGridViewCellEventArgs.ColumnIndex屬性來判斷按下按鈕資料行是否發生點擊。In the event handler, you can use the DataGridViewCellEventArgs.ColumnIndex property to determine whether the click occurred a the button column. 您可以使用DataGridViewCellEventArgs.RowIndex屬性來判斷在特定按鈕資料格中是否發生按一下。You can use the DataGridViewCellEventArgs.RowIndex property to determine whether the click occurred in a particular button cell.

資料行的資料格相關屬性是範本資料格之類似名稱屬性的包裝函式。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.

注意

啟用視覺化樣式時, 按鈕資料行中的按鈕會使用ButtonRenderer繪製, 而透過屬性DefaultCellStyle指定的儲存格樣式則不會有任何作用。When visual styles are enabled, the buttons in a button column are painted using a ButtonRenderer, and cell styles specified through properties such as DefaultCellStyle have no effect.

給繼承者的注意事項

當您衍生自DataGridViewButtonCell並將新的屬性加入至衍生類別時, 請務必覆Clone()寫方法, 以便在複製作業期間複製新的屬性。When you derive from DataGridViewButtonCell 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.

建構函式

DataGridViewButtonCell()

初始化 DataGridViewButtonCell 類別的新執行個體。Initializes a new instance of the DataGridViewButtonCell class.

屬性

AccessibilityObject

取得指定給 DataGridViewCell.DataGridViewCellAccessibleObjectDataGridViewCellGets the DataGridViewCell.DataGridViewCellAccessibleObject assigned to the DataGridViewCell.

(繼承來源 DataGridViewCell)
ColumnIndex

取得這個儲存格的資料行索引。Gets the column index for this cell.

(繼承來源 DataGridViewCell)
ContentBounds

取得圍住儲存格內容區域的周框。Gets the bounding rectangle that encloses the cell's content area.

(繼承來源 DataGridViewCell)
ContextMenuStrip

取得或設定與儲存格相關聯的捷徑功能表。Gets or sets the shortcut menu associated with the cell.

(繼承來源 DataGridViewCell)
DataGridView

取得與這個項目有關聯的 DataGridView 控制項。Gets the DataGridView control associated with this element.

(繼承來源 DataGridViewElement)
DefaultNewRowValue

取得新資料錄之資料列中儲存格的預設值。Gets the default value for a cell in the row for new records.

(繼承來源 DataGridViewCell)
Displayed

取得值,該值表示儲存格目前是否顯示於螢幕上。Gets a value that indicates whether the cell is currently displayed on-screen.

(繼承來源 DataGridViewCell)
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.

(繼承來源 DataGridViewCell)
EditType

取得儲存格的裝載編輯控制項型別。Gets the type of the cell's hosted editing control.

ErrorIconBounds

取得儲存格之錯誤圖示的界限。Gets the bounds of the error icon for the cell.

(繼承來源 DataGridViewCell)
ErrorText

取得或設定文字,描述與儲存格相關聯的錯誤狀況。Gets or sets the text describing an error condition associated with the cell.

(繼承來源 DataGridViewCell)
FlatStyle

取得或設定可決定按鈕外觀的樣式。Gets or sets the style determining the button's appearance.

FormattedValue

取得儲存格的格式化值,以供顯示。Gets the value of the cell as formatted for display.

(繼承來源 DataGridViewCell)
FormattedValueType

取得與儲存格相關的格式化值的型別。Gets the type of the formatted value associated with the cell.

Frozen

取得指出是否已凍結此儲存格的值。Gets a value indicating whether the cell is frozen.

(繼承來源 DataGridViewCell)
HasStyle

取得指出是否已經設定 Style 屬性的值。Gets a value indicating whether the Style property has been set.

(繼承來源 DataGridViewCell)
InheritedState

取得儲存格的目前狀態,是繼承其資料列和資料行的狀態。Gets the current state of the cell as inherited from the state of its row and column.

(繼承來源 DataGridViewCell)
InheritedStyle

取得目前套用至儲存格的樣式。Gets the style currently applied to the cell.

(繼承來源 DataGridViewCell)
IsInEditMode

取得指出目前是否正在編輯這個儲存格的值。Gets a value indicating whether this cell is currently being edited.

(繼承來源 DataGridViewCell)
OwningColumn

取得包含這個儲存格的資料行。Gets the column that contains this cell.

(繼承來源 DataGridViewCell)
OwningRow

取得包含這個儲存格的資料列。Gets the row that contains this cell.

(繼承來源 DataGridViewCell)
PreferredSize

取得能夠容納儲存格的矩形區域大小 (以像素為單位)。Gets the size, in pixels, of a rectangular area into which the cell can fit.

(繼承來源 DataGridViewCell)
ReadOnly

取得或設定值,指出是否可以編輯儲存格的資料。Gets or sets a value indicating whether the cell's data can be edited.

(繼承來源 DataGridViewCell)
Resizable

取得指出儲存格是否可以調整大小的值。Gets a value indicating whether the cell can be resized.

(繼承來源 DataGridViewCell)
RowIndex

取得儲存格的父資料列索引。Gets the index of the cell's parent row.

(繼承來源 DataGridViewCell)
Selected

取得或設定值,指出是否已選取此儲存格。Gets or sets a value indicating whether the cell has been selected.

(繼承來源 DataGridViewCell)
Size

取得儲存格的大小。Gets the size of the cell.

(繼承來源 DataGridViewCell)
State

取得此項目的使用者介面 (UI) 狀態。Gets the user interface (UI) state of the element.

(繼承來源 DataGridViewElement)
Style

取得或設定儲存格的樣式。Gets or sets the style for the cell.

(繼承來源 DataGridViewCell)
Tag

取得或設定物件,其中包含儲存格的相關補充資料。Gets or sets the object that contains supplemental data about the cell.

(繼承來源 DataGridViewCell)
ToolTipText

取得或設定與這個儲存格相關聯的工具提示文字。Gets or sets the ToolTip text associated with this cell.

(繼承來源 DataGridViewCell)
UseColumnTextForButtonValue

取得或設定值,指出主控資料行的文字是否會出現在儲存格所顯示的按鈕上。Gets or sets a value indicating whether the owning column's text will appear on the button displayed by the cell.

Value

取得或設定與這個儲存格相關聯的值。Gets or sets the value associated with this cell.

(繼承來源 DataGridViewCell)
ValueType

取得或設定儲存格中值的資料型別。Gets or sets the data type of the values in the cell.

Visible

取得指出儲存格是在已隱藏資料列或是資料行中的值。Gets a value indicating whether the cell is in a row or column that has been hidden.

(繼承來源 DataGridViewCell)

方法

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

根據指定的準則,修改輸入儲存格框線樣式。Modifies the input cell border style according to the specified criteria.

(繼承來源 DataGridViewCell)
BorderWidths(DataGridViewAdvancedBorderStyle)

傳回 Rectangle,表示所有儲存格邊界的寬度。Returns a Rectangle that represents the widths of all the cell margins.

(繼承來源 DataGridViewCell)
ClickUnsharesRow(DataGridViewCellEventArgs)

指出當按下儲存格時,儲存格的資料列是否會取消共用。Indicates whether the cell's row will be unshared when the cell is clicked.

(繼承來源 DataGridViewCell)
Clone()

建立與這個儲存格完全相同的複本。Creates an exact copy of this cell.

ContentClickUnsharesRow(DataGridViewCellEventArgs)

指出當按下儲存格內容時,儲存格的資料列是否會取消共用。Indicates whether the cell's row will be unshared when the cell's content is clicked.

(繼承來源 DataGridViewCell)
ContentDoubleClickUnsharesRow(DataGridViewCellEventArgs)

指出當按兩下儲存格內容時,儲存格的資料列是否會取消共用。Indicates whether the cell's row will be unshared when the cell's content is double-clicked.

(繼承來源 DataGridViewCell)
CreateAccessibilityInstance()

DataGridViewButtonCell 建立新的可存取物件。Creates a new accessible object for the DataGridViewButtonCell.

DetachEditingControl()

DataGridView 中移除儲存格的編輯控制項。Removes the cell's editing control from the DataGridView.

(繼承來源 DataGridViewCell)
Dispose()

釋放 DataGridViewCell 所使用的所有資源。Releases all resources used by the DataGridViewCell.

(繼承來源 DataGridViewCell)
Dispose(Boolean)

釋放 DataGridViewCell 所使用的 Unmanaged 資源,並選擇性地釋放 Managed 資源。Releases the unmanaged resources used by the DataGridViewCell and optionally releases the managed resources.

(繼承來源 DataGridViewCell)
DoubleClickUnsharesRow(DataGridViewCellEventArgs)

指出當按兩下儲存格時,儲存格的資料列是否會取消共用。Indicates whether the cell's row will be unshared when the cell is double-clicked.

(繼承來源 DataGridViewCell)
EnterUnsharesRow(Int32, Boolean)

指出當焦點移至儲存格時,是否將取消共用父資料列。Indicates whether the parent row will be unshared when the focus moves to the cell.

(繼承來源 DataGridViewCell)
Equals(Object)

判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object.

(繼承來源 Object)
GetClipboardContent(Int32, Boolean, Boolean, Boolean, Boolean, String)

擷取儲存格的已格式化的值,以複製到 ClipboardRetrieves the formatted value of the cell to copy to the Clipboard.

(繼承來源 DataGridViewCell)
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)

使用預設的 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.

(繼承來源 DataGridViewCell)
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.

(繼承來源 DataGridViewCell)
GetErrorIconBounds(Graphics, DataGridViewCellStyle, Int32)

傳回圍住儲存格的錯誤圖示之週框 (如果有此圖示)。Returns the bounding rectangle that encloses the cell's error icon, if one is displayed.

GetErrorText(Int32)

傳回表示儲存格錯誤的字串。Returns a string that represents the error for the cell.

(繼承來源 DataGridViewCell)
GetFormattedValue(Object, Int32, DataGridViewCellStyle, TypeConverter, TypeConverter, DataGridViewDataErrorContexts)

取得儲存格的格式化值,以供顯示。Gets the value of the cell as formatted for display.

(繼承來源 DataGridViewCell)
GetHashCode()

做為預設雜湊函式。Serves as the default hash function.

(繼承來源 Object)
GetInheritedContextMenuStrip(Int32)

取得目前儲存格的繼承捷徑功能表。Gets the inherited shortcut menu for the current cell.

(繼承來源 DataGridViewCell)
GetInheritedState(Int32)

傳回值,指出儲存格的目前狀態是從其資料列和資料行的狀態繼承而來。Returns a value indicating the current state of the cell as inherited from the state of its row and column.

(繼承來源 DataGridViewCell)
GetInheritedStyle(DataGridViewCellStyle, Int32, Boolean)

取得套用到儲存格的樣式。Gets the style applied to the cell.

(繼承來源 DataGridViewCell)
GetPreferredSize(Graphics, DataGridViewCellStyle, Int32, Size)

計算儲存格的慣用大小 (以像素為單位)。Calculates the preferred size, in pixels, of the cell.

GetSize(Int32)

取得儲存格的大小。Gets the size of the cell.

(繼承來源 DataGridViewCell)
GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(繼承來源 Object)
GetValue(Int32)

擷取與按鈕關聯的文字。Retrieves the text associated with the button.

InitializeEditingControl(Int32, Object, DataGridViewCellStyle)

初始化用來編輯儲存格的控制項。Initializes the control used to edit the cell.

(繼承來源 DataGridViewCell)
KeyDownUnsharesRow(KeyEventArgs, Int32)

指出當焦點在資料列中的儲存格上並按下按鍵時,是否會取消共用資料列。Indicates whether a row is unshared if a key is pressed while the focus is on a cell in the row.

KeyEntersEditMode(KeyEventArgs)

判斷是否應該根據指定的按鍵啟動編輯模式。Determines if edit mode should be started based on the given key.

(繼承來源 DataGridViewCell)
KeyPressUnsharesRow(KeyPressEventArgs, Int32)

指出如果當焦點在資料列中的儲存格時按下按鍵,是否會取消資料列的共用。Indicates whether a row will be unshared if a key is pressed while a cell in the row has focus.

(繼承來源 DataGridViewCell)
KeyUpUnsharesRow(KeyEventArgs, Int32)

指出當焦點在資料列中的儲存格上並釋放按鍵時,是否會取消共用資料列。Indicates whether a row is unshared when a key is released while the focus is on a cell in the row.

LeaveUnsharesRow(Int32, Boolean)

指出當焦點移出資料列中的儲存格時,是否取消共用該資料列。Indicates whether a row will be unshared when the focus leaves a cell in the row.

(繼承來源 DataGridViewCell)
MemberwiseClone()

建立目前 Object 的淺層複本 (Shallow Copy)。Creates a shallow copy of the current Object.

(繼承來源 Object)
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.

(繼承來源 DataGridViewCell)
MouseDoubleClickUnsharesRow(DataGridViewCellMouseEventArgs)

指出當使用者按兩下資料列中的儲存格時,是否取消共用該資料列。Indicates whether a row will be unshared if the user double-clicks a cell in the row.

(繼承來源 DataGridViewCell)
MouseDownUnsharesRow(DataGridViewCellMouseEventArgs)

指出當指標位於某資料列的儲存格上,並按住滑鼠按鈕時,是否會取消共用該資料列。Indicates whether a row will be unshared when the mouse button is held down while the pointer is on a cell in the row.

MouseEnterUnsharesRow(Int32)

指出當滑鼠指標移到某資料列的儲存格上方時,是否取消共用該資料列。Indicates whether a row will be unshared when the mouse pointer moves over a cell in the row.

MouseLeaveUnsharesRow(Int32)

指示當滑鼠指標離開某列時,該列是否共用。Indicates whether a row will be unshared when the mouse pointer leaves the row.

MouseMoveUnsharesRow(DataGridViewCellMouseEventArgs)

指出當滑鼠指標移到某資料列的儲存格上方時,是否取消共用該資料列。Indicates whether a row will be unshared when the mouse pointer moves over a cell in the row.

(繼承來源 DataGridViewCell)
MouseUpUnsharesRow(DataGridViewCellMouseEventArgs)

指出當指標位於某資料列的儲存格上,並釋放滑鼠按鈕時,是否會取消共用該資料列。Indicates whether a row will be unshared when the mouse button is released while the pointer is on a cell in the row.

OnClick(DataGridViewCellEventArgs)

當按下儲存格時呼叫。Called when the cell is clicked.

(繼承來源 DataGridViewCell)
OnContentClick(DataGridViewCellEventArgs)

當按下儲存格內容時呼叫。Called when the cell's contents are clicked.

(繼承來源 DataGridViewCell)
OnContentDoubleClick(DataGridViewCellEventArgs)

當按兩下儲存格內容時呼叫。Called when the cell's contents are double-clicked.

(繼承來源 DataGridViewCell)
OnDataGridViewChanged()

當儲存格的 DataGridView 屬性變更時呼叫。Called when the DataGridView property of the cell changes.

(繼承來源 DataGridViewCell)
OnDoubleClick(DataGridViewCellEventArgs)

當按兩下儲存格時呼叫。Called when the cell is double-clicked.

(繼承來源 DataGridViewCell)
OnEnter(Int32, Boolean)

當焦點移至儲存格時呼叫。Called when the focus moves to a cell.

(繼承來源 DataGridViewCell)
OnKeyDown(KeyEventArgs, Int32)

當焦點 (Focus) 在儲存格上,按下字元鍵時呼叫。Called when a character key is pressed while the focus is on the cell.

OnKeyPress(KeyPressEventArgs, Int32)

當焦點在儲存格上,按下按鍵時呼叫。Called when a key is pressed while the focus is on a cell.

(繼承來源 DataGridViewCell)
OnKeyUp(KeyEventArgs, Int32)

當焦點在儲存格上,放開字元鍵時呼叫。Called when a character key is released while the focus is on the cell.

OnLeave(Int32, Boolean)

當焦點從儲存格移動時呼叫。Called when the focus moves from the cell.

OnMouseClick(DataGridViewCellMouseEventArgs)

當滑鼠指標在儲存格上,使用者按一下滑鼠按鈕時呼叫。Called when the user clicks a mouse button while the pointer is on a cell.

(繼承來源 DataGridViewCell)
OnMouseDoubleClick(DataGridViewCellMouseEventArgs)

當滑鼠指標在儲存格上,使用者按兩下滑鼠按鈕時呼叫。Called when the user double-clicks a mouse button while the pointer is on a cell.

(繼承來源 DataGridViewCell)
OnMouseDown(DataGridViewCellMouseEventArgs)

當指標位於儲存格上,按住滑鼠按鈕時呼叫。Called when the mouse button is held down while the pointer is on the cell.

OnMouseEnter(Int32)

當滑鼠指標移到儲存格上方時呼叫。Called when the mouse pointer moves over a cell.

(繼承來源 DataGridViewCell)
OnMouseLeave(Int32)

當滑鼠指標移出儲存格時呼叫。Called when the mouse pointer moves out of the cell.

OnMouseMove(DataGridViewCellMouseEventArgs)

當滑鼠指標移至儲存格上方時呼叫。Called when the mouse pointer moves while it is over the cell.

OnMouseUp(DataGridViewCellMouseEventArgs)

當指標位於儲存格上,放開鼠按鈕時呼叫。Called when the mouse button is released while the pointer is on the cell.

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

繪製目前的 DataGridViewButtonCellPaints the current DataGridViewButtonCell.

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

繪製目前 DataGridViewCell 的框線。Paints the border of the current DataGridViewCell.

(繼承來源 DataGridViewCell)
PaintErrorIcon(Graphics, Rectangle, Rectangle, String)

繪製目前 DataGridViewCell 的錯誤圖示。Paints the error icon of the current DataGridViewCell.

(繼承來源 DataGridViewCell)
ParseFormattedValue(Object, DataGridViewCellStyle, TypeConverter, TypeConverter)

將為了顯示而格式化的值轉換成實際的儲存格值。Converts a value formatted for display to an actual cell value.

(繼承來源 DataGridViewCell)
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.

(繼承來源 DataGridViewCell)
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.

(繼承來源 DataGridViewCell)
RaiseCellClick(DataGridViewCellEventArgs)

引發 CellClick 事件。Raises the CellClick event.

(繼承來源 DataGridViewElement)
RaiseCellContentClick(DataGridViewCellEventArgs)

引發 CellContentClick 事件。Raises the CellContentClick event.

(繼承來源 DataGridViewElement)
RaiseCellContentDoubleClick(DataGridViewCellEventArgs)

引發 CellContentDoubleClick 事件。Raises the CellContentDoubleClick event.

(繼承來源 DataGridViewElement)
RaiseCellValueChanged(DataGridViewCellEventArgs)

引發 CellValueChanged 事件。Raises the CellValueChanged event.

(繼承來源 DataGridViewElement)
RaiseDataError(DataGridViewDataErrorEventArgs)

引發 DataError 事件。Raises the DataError event.

(繼承來源 DataGridViewElement)
RaiseMouseWheel(MouseEventArgs)

引發 MouseWheel 事件。Raises the MouseWheel event.

(繼承來源 DataGridViewElement)
SetValue(Int32, Object)

設定儲存格的值。Sets the value of the cell.

(繼承來源 DataGridViewCell)
ToString()

傳回儲存格的字串表示。Returns the string representation of the cell.

適用於

另請參閱