Click here to Skip to main content
15,902,445 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
hello every one.....

i hve one datagrid view in vb.net

when i click on cell i get value in textboxes....then i click on delete button...

nd i rebind my datagridview....but i wnt to go in lastposition which one i selected....

like my code is...

public sub bidngridview()

dim adap as oracledataAdapter
adap=new OracleDataAdapter("select * from subcategory",dl.con)
ds=new dataset()
adap.fill(ds)
DataGridView1.DataSource=ds.Table(0)

End Sub

Private Sub btnDelete_click()
cmd=new oracleCommand("delete from subcategory where autoid='"+grdAutodi.ToString()+"'",dl.con)
cmd.ExecuteOralceNonQuer("commit")
call bindgridview()
DataGridView1.Rows(crtrow).Selected = True
DataGridView1.Refresh


end sub



crtrow is my last Index of selected rows....


Thanks & Regards

Daljeet Singh
Software Developer
Posted

Hi
Just remove the line
DataGridView1.Refresh

from your Delete click procedure, this will solve the issue.


Thanx,
Adil...:))
 
Share this answer
 
If you rebind, you will lose your selection. If you must do this, get the selection first, then mark it selected again after binding.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900