Jump to content

How to count rows of Table Adapter (VB)

FaiL___

Hi, I am doing some coursework, but struggling getting the row count for a table.

 

At the minute I am doing:


/EndOfList = DataGridView1.Rowcount - 1

This isn't working.

Cheers

There are 10 types of people in the world. Those that understand binary and those that don't.

Link to comment
Share on other sites

Link to post
Share on other sites

do you not want to use DataGridView1.Rows.Count ?

The Rowcount property might not be setup yet, i dont you have only given one line.

             ☼

ψ ︿_____︿_ψ_   

Link to comment
Share on other sites

Link to post
Share on other sites

The only fault I can spot is the forward slash. You may be declaring the EndOfList wrong or using it wrong but for that we'd need more context.

 

This works fine for me:

Public Class Form1
    Dim EndOfList As Integer = 0
    Private Sub DataGridView1_CellEndEdit(sender As Object, e As DataGridViewCellEventArgs) Handles DataGridView1.CellEndEdit
        EndOfList = DataGridView1.RowCount - 1
        Me.Text = EndOfList.ToString
    End Sub
End Class

 

Link to comment
Share on other sites

Link to post
Share on other sites

On 13/12/2016 at 1:01 PM, Naeaes said:

The only fault I can spot is the forward slash. You may be declaring the EndOfList wrong or using it wrong but for that we'd need more context.

 

This works fine for me:


Public Class Form1
    Dim EndOfList As Integer = 0
    Private Sub DataGridView1_CellEndEdit(sender As Object, e As DataGridViewCellEventArgs) Handles DataGridView1.CellEndEdit
        EndOfList = DataGridView1.RowCount - 1
        Me.Text = EndOfList.ToString
    End Sub
End Class

 

I can give more context later, but what I'm trying to do is output data from a database into a list box (via a table adapter)

There are 10 types of people in the world. Those that understand binary and those that don't.

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×