.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month

Home >> Forum >> VB.Net >> Post New QuestionBookmark and Share Subscribe to Forum

Reordering of datagridview using up and down button

Posted By: thushara     Posted Date: January 12, 2011    Points:2   Category :VB.Net
For reordeering of rows in a bounded datagridview, i got some code
from the net.I am posting it here.But while i use this code, I am getting error in the first line itself saying that CurrentRowIndex
is not a member of system.windows.forms.datagridview. )Is it b;cuz of 3.5 framework.??).
Can any body help me to correct the codings.

This one is for the UP button....

Dim Index As Integer = datagrid.CurrentRowIndex

If Index > 0 And Index <= datagrid.VisibleRowCount - 1 Then
For i = 0 To datagrid.VisibleColumnCount - 1
CurrInd = datagrid.CurrentRowIndex()
Obj = datagrid.Item(CurrInd - 1, i)
datagrid.Item(CurrInd - 1, i) = datagrid.Item(CurrInd, i)
datagrid.Item(CurrInd, i) = Obj
datagrid.CurrentRowIndex = CurrInd - 1
End If

Author: Blessy Baby             
Posted Date: February 11, 2011     Points: 5   


why do not you try this using sql query or you can easily do this using linq. For each sort click, sort the existing data using linq and bind grid again

datagrid.Datasource=datacollection.OrderByDescending(c=>c.ApproverID)or datacollection.OrderBy(c=>c.ApproverID)

Blessy Baby
Project Lead
Digitalmesh Softech India (p) Limited

Post Reply

You must Sign In To post reply
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend