DataGridViewRowCollection.GetRowCount メソッド
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)

Dim instance As DataGridViewRowCollection Dim includeFilter As DataGridViewElementStates Dim returnValue As Integer returnValue = instance.GetRowCount(includeFilter)
戻り値
DataGridViewRowCollection 内の includeFilter で指定された属性を持つ DataGridViewRow オブジェクトの数。


このメソッドを使用して、選択した行の数を取得するコード例を次に示します。
Private Sub selectedRowsButton_Click( _ ByVal sender As Object, ByVal e As System.EventArgs) _ Handles selectedRowsButton.Click Dim selectedRowCount As Integer = _ dataGridView1.Rows.GetRowCount(DataGridViewElementStates.Selected) If selectedRowCount > 0 Then Dim sb As New System.Text.StringBuilder() Dim i As Integer For i = 0 To selectedRowCount - 1 sb.Append("Row: ") sb.Append(dataGridView1.SelectedRows(i).Index.ToString()) sb.Append(Environment.NewLine) Next i sb.Append("Total: " + selectedRowCount.ToString()) MessageBox.Show(sb.ToString(), "Selected Rows") End If End Sub
private void selectedRowsButton_Click(object sender, System.EventArgs e) { Int32 selectedRowCount = dataGridView1.Rows.GetRowCount(DataGridViewElementStates.Selected); if (selectedRowCount > 0) { System.Text.StringBuilder sb = new System.Text.StringBuilder(); for (int i = 0; i < selectedRowCount; i++) { sb.Append("Row: "); sb.Append(dataGridView1.SelectedRows[i].Index.ToString()); sb.Append(Environment.NewLine); } sb.Append("Total: " + selectedRowCount.ToString()); MessageBox.Show(sb.ToString(), "Selected Rows"); } }

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からDataGridViewRowCollection.GetRowCount メソッドを検索する場合は、下記のリンクをクリックしてください。

- DataGridViewRowCollection.GetRowCount メソッドのページへのリンク