row counter

D

Doug

Hi

I have a data grid view that returns values from a sql lookup.
At the bottom of the area that displys the datagridview, I have a label
called rowCount that displays the number of rows returned, but when ther
datagridview returns no values the first line in the datagridview has a '*'
on the left column and the counter claims this has one row.
string rowCount=dgMainView.RowCount.ToString();



Is there a better way to determine the number of rows returned to a
datagridview?



Thanks



Doug
 
D

Dave Sexton

Hi Doug,

Get the count from the actual DataSource, which I assume is a DataTable:

string rowCount = lookup.Rows.Count.ToString();
 
S

Slug

The * means that row is for adding a new record... configure your datagrid
to not allow new records (unless you need to of course) and that row should
go away.

If I am understanding you correctly that is.....
 
D

Doug

Thanks Dave,

Works well.

Do you know if it is possible to prevent the datagridview from displaying
the additional row at the bottom line?

my datagridview is populated with dgMainView.DataSource =
DS.Tables["vars"].DefaultView;

Thanks

Doug
 
D

Dave Sexton

Hi Doug,

Set AllowUserToAddRows to false.

--
Dave Sexton

Doug said:
Thanks Dave,

Works well.

Do you know if it is possible to prevent the datagridview from displaying
the additional row at the bottom line?

my datagridview is populated with dgMainView.DataSource =
DS.Tables["vars"].DefaultView;

Thanks

Doug
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top