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 窗体 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.CellClickDataGridView.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

获取或设置与此单元格关联的 ToolTip 文本。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 占用的非托管资源,还可以另外再释放托管资源。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)

检索要复制到 Clipboard 的单元格的已设置格式的值。Retrieves 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 的浅表副本。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)

当焦点位于单元格上并按字符键时调用。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.

适用于

另请参阅