Using a DevExpress XtraGrid and Trying to Move Records Up or Down


Author
Message
Buffie
Buffie
StrataFrame User (271 reputation)StrataFrame User (271 reputation)StrataFrame User (271 reputation)StrataFrame User (271 reputation)StrataFrame User (271 reputation)StrataFrame User (271 reputation)StrataFrame User (271 reputation)StrataFrame User (271 reputation)StrataFrame User (271 reputation)
Group: StrataFrame Users
Posts: 119, Visits: 11K
I have a DevExpress XtraGrid filled with a Business Binding Source. I am trying to follow a Sample that allows user to move a record up or down by clicking a button.

But, the Sample uses a DataTable and not a BBS or BO so I am having trouble converting some of the code.

Dim view As GridView = gridView1
view.GridControl.Focus()
Dim index As Integer = view.FocusedRowHandle
If index <= 0 Then
Return
End If
Dim row1 As DataRow = view.GetDataRow(index)
Dim row2 As DataRow = view.GetDataRow(index - 1)
Dim val1 As Object = row1(OrderFieldName)
Dim val2 As Object = row2(OrderFieldName)
row1(OrderFieldName) = val2
row2(OrderFieldName) = val1
view.FocusedRowHandle = index - 1


What I am not sure how to convert is the lines that involve the DataRows.

I would appreciate any help I could get and if anyone has a Xtragrid allowing moving records I would appreciate any hints or advice.

TIA


Replies
Terry Bottorff
Terry Bottorff
Advanced StrataFrame User (676 reputation)Advanced StrataFrame User (676 reputation)Advanced StrataFrame User (676 reputation)Advanced StrataFrame User (676 reputation)Advanced StrataFrame User (676 reputation)Advanced StrataFrame User (676 reputation)Advanced StrataFrame User (676 reputation)Advanced StrataFrame User (676 reputation)Advanced StrataFrame User (676 reputation)
Group: Forum Members
Posts: 448, Visits: 12K
I did set the SortOrder so I had that piece but I am confused. After I create the new BO based on the record that has Focus what am I to do with it?
I see it does have the JudgesSheetPositionNumber value in boInGridView.JudgesSheetPositionNumber and certainly when I add 1 to that it will tell me the position it is going but I don't know what to do from there? 

Also, the following line of code would not let me put BO1 on the end.

boInGridView = TryCast(Me.GridView1.GetRow(index), ResultsPerfsChecksTimedEventBO)

Yes Edhy, I agree I was planning on validating the move when in first position and last position.

Edhy Rijo
E
StrataFrame VIP (3.8K reputation)StrataFrame VIP (3.8K reputation)StrataFrame VIP (3.8K reputation)StrataFrame VIP (3.8K reputation)StrataFrame VIP (3.8K reputation)StrataFrame VIP (3.8K reputation)StrataFrame VIP (3.8K reputation)StrataFrame VIP (3.8K reputation)StrataFrame VIP (3.8K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Terry Bottorff (9/7/2014)

Also, the following line of code would not let me put BO1 on the end.

boInGridView = TryCast(Me.GridView1.GetRow(index), ResultsPerfsChecksTimedEventBO)

That is correct because when you Cast() or TryCast() you have to pass the class type as a parameter not an instance of a class which in this case would be the BO1, so my code is correct.
I know it can be confusing but if you look closely it is actually very simple. 

I have to go out now and will be back in 2 hours, if you want email me your phone and I will call you to make a remote session and see your project, this could get done in 10-20 minutes and would be easier to explain.

Edhy Rijo

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...





Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search