hi everybody , my Question is , how i can get the last row in my datagridview

thanx in advance :)

Recommended Answers

All 8 Replies

Using the rowindex. or get the number of rows in grid and select the last row

ty , other question please after i get the last row in my dgv how i can make my cursor wait in cell i this row

U need to set the activecell proerty or active row property to set the cursor

as Pgmer said you can use the rowindex to get your last row here is code to get the last index .

dim lastIndex as integer
lastIndex=datagridview.rows.count -1 ' this code will give you the last index of row. 

Regards

dim last as integer

dim last as integer
last=datagridview1.rows.count-1

getting last row and for focus there
when adding new row or directly focus there

datagridview1.currentcell=datagridview1(0,datagridview1.rowindex)

like this article

dim last as integer
last=datagridview1.rows.count-1
datagridview1.currentcell=datagridview1(0,last)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.