DataGrid.Select(Int32) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Selects a specified row.
public:
void Select(int row);
public void Select (int row);
override this.Select : int -> unit
Public Sub Select (row As Integer)
Parameters
- row
- Int32
The index of the row to select.
Examples
The following code example demonstrates the use of this member.
// Select the first row.
private:
void button7_Click( Object^ /*sender*/, EventArgs^ /*e*/ )
{
myDataGrid->Select(0);
}
// Check if the first row is selected.
private:
void button8_Click( Object^ /*sender*/, EventArgs^ /*e*/ )
{
if ( myDataGrid->IsSelected( 0 ) )
{
MessageBox::Show( "Row selected", "Message", MessageBoxButtons::OK, MessageBoxIcon::Exclamation );
}
else
{
MessageBox::Show( "Row not selected", "Message", MessageBoxButtons::OK, MessageBoxIcon::Exclamation );
}
}
// Deselect the first row.
void button11_Click( Object^ /*sender*/, EventArgs^ /*e*/ )
{
myDataGrid->UnSelect( 0 );
}
// Select the first row.
private void button7_Click(object sender, EventArgs e)
{
myDataGrid.Select(0);
}
// Check if the first row is selected.
private void button8_Click(object sender, EventArgs e)
{
if(myDataGrid.IsSelected(0))
{
MessageBox.Show("Row selected",
"Message", MessageBoxButtons.OK,
MessageBoxIcon.Exclamation);
}
else
{
MessageBox.Show("Row not selected",
"Message", MessageBoxButtons.OK,
MessageBoxIcon.Exclamation);
}
}
// Deselect the first row.
private void button11_Click(object sender, EventArgs e)
{
myDataGrid.UnSelect(0);
}
' Select the first row.
Private Sub button7_Click(ByVal sender As Object, ByVal e As EventArgs) Handles button7.Click
myDataGrid.Select(0)
End Sub
' Check if the first row is selected.
Private Sub button8_Click(ByVal sender As Object, ByVal e As EventArgs) Handles button8.Click
If myDataGrid.IsSelected(0) Then
MessageBox.Show("Row selected", "Message", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
Else
MessageBox.Show("Row not selected", "Message", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
End If
End Sub
' Deselect the first row.
Private Sub button11_Click(ByVal sender As Object, ByVal e As EventArgs) Handles button11.Click
myDataGrid.UnSelect(0)
End Sub
Remarks
Use this method with the IsSelected, UnSelect, and ResetSelection methods to manipulate the selection state of a particular row.
Applies to
意見反應
https://aka.ms/ContentUserFeedback。
即將登場:在 2024 年,我們將逐步淘汰 GitHub 問題作為內容的意見反應機制,並將它取代為新的意見反應系統。 如需詳細資訊,請參閱:提交並檢視相關的意見反應