Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old September 21st, 2011, 03:19 PM
Registered User
Points: 5, Level: 1
Points: 5, Level: 1 Points: 5, Level: 1 Points: 5, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default how to move rows in a datagrid with VB

I'm enhancing an older app and have be working with ItemCommands to move rows in the datagrid up or down. Can anyone guide me to the best way to do this with examples? Any help is greatly appreciated.
Reply With Quote
  #2 (permalink)  
Old October 19th, 2011, 05:45 AM
Registered User
Points: 9, Level: 1
Points: 9, Level: 1 Points: 9, Level: 1 Points: 9, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2011
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I have made this sub procedure. Try by using it on Button click event in your code. Hope this will work as per your requirement.

Code:
Public Sub MoveUp(ByRef firstRow As System.Windows.Forms.DataGridViewRow, ByRef nextRow As System.Windows.Forms.DataGridViewRow)
'Create a temporary value
Dim temp As Object
Dim temp2 As Object

'Loop through each cell in the firstRow datagridview
Dim i As Integer
For i = 0 To firstRow.Cells.Count - 1
'If the cell isn't read only, then swap them.
If firstRow.Cells(i).ReadOnly = False Then
'use the temp object to swap the cell values.
temp = firstRow.Cells(i).Value
temp2 = nextRow.Cells(i).Value

firstRow.Cells(i).Value = temp2
nextRow.Cells(i).Value = temp
End If
Next
End Sub
Reply With Quote
  #3 (permalink)  
Old October 20th, 2012, 04:00 AM
Registered User
Points: 3, Level: 1
Points: 3, Level: 1 Points: 3, Level: 1 Points: 3, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2012
Location: Parkersburg
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I have done this code but it is in c#,so will it help you?

manuka honey
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to move rows in a table bucky483 Javascript How-To 10 March 27th, 2017 12:57 AM
vb 2010 datatable move next, move previouse bigway .NET 4 and Visual Studio 2010 General Discussions 1 July 13th, 2011 03:55 AM
move next rows in DataGrid < > prop. not correct fbailey ASP.NET 1.0 and 1.1 Basics 3 September 5th, 2007 10:17 AM
Move Datagrid rows michael29 ASP.NET 1.0 and 1.1 Professional 1 April 24th, 2007 05:31 PM
move rows to top with cells in columnA filled RED alienscript Excel VBA 2 December 2nd, 2003 12:51 PM



All times are GMT -4. The time now is 10:10 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.