DataGridView.SelectAll 方法

定义

选择 DataGridView 中的所有单元格。Selects all the cells in the DataGridView.

public:
 void SelectAll();
public void SelectAll ();
member this.SelectAll : unit -> unit
Public Sub SelectAll ()

示例

下面的代码示例演示如何使用 SelectAll 方法。The following code example demonstrates the use of the SelectAll method. 若要运行此示例,请将代码粘贴到包含名为 @no__t 的 @no__t 0 的窗体和一个名为 @no__t 的 Button,并确保所有事件都与事件处理程序相关联。To run this example, paste the code into a form that contains a DataGridView named dataGridView1 and a Button named selectAllButton, and ensure all events are associated with their event handlers.

private void selectAllButton_Click(object sender, EventArgs e)
{
    dataGridView1.SelectAll();
}
Private Sub selectAllButton_Click(ByVal sender As Object, _
    ByVal e As EventArgs) Handles clearSelectionButton.Click

    dataGridView1.SelectAll()

End Sub

注解

当 @no__t 为列选择模式并且调用此方法时,每个列的 Selected 属性将设置为 true,并且每行的 @no__t 属性设置为 falseWhen the DataGridView is in column-selection mode and this method is called, each column's Selected property is set to true, and each row's Selected property is set to false.

相反,当 @no__t 为行选择模式并且调用此方法时,每个行的 @no__t 属性设置为 true,并且每个列的 Selected 属性都设置为 falseConversely, when the DataGridView is in row-selection mode and this method is called, each row's Selected property is set to true, and each column's Selected property is set to false.

适用于

另请参阅