次の方法で共有


DataGrid.IsSelected メソッド

指定した行が選択されているかどうかを示す値を取得します。

Public Function IsSelected( _
   ByVal row As Integer _) As Boolean
[C#]
public bool IsSelected(introw);
[C++]
public: bool IsSelected(introw);
[JScript]
public function IsSelected(
   row : int) : Boolean;

パラメータ

  • row
    指定した行の番号。

戻り値

行が選択されている場合は true 。それ以外の場合は false

使用例

 
' 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 'button8_Click

' Deselect the first row.
Private Sub button11_Click(ByVal sender As Object, ByVal e As EventArgs) Handles button11.Click
    myDataGrid.UnSelect(0)
End Sub 'button11_Click


[C#] 
// 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);
}

[C++] 
private:
    // Check if the first row is selected.
    void button8_Click(Object* /*sender*/, EventArgs* /*e*/) {
        if (myDataGrid->IsSelected(0)) {
            MessageBox::Show(S"Row selected",
                S"Message",   MessageBoxButtons::OK,
                MessageBoxIcon::Exclamation);
        } else {
            MessageBox::Show(S"Row not selected",
                S"Message",   MessageBoxButtons::OK,
                MessageBoxIcon::Exclamation);
        }
    }
    // Deselect the first row.
    void button11_Click(Object* /*sender*/, EventArgs* /*e*/) {
        myDataGrid->UnSelect(0);
    }

[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ, .NET Compact Framework - Windows CE .NET

参照

DataGrid クラス | DataGrid メンバ | System.Windows.Forms 名前空間