473,386 Members | 1,726 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

CurrencyManager Qestion

I think I need to use a currency manager for this job but I'm not sure
how to make it work.
Using a dataview as the datasource for a datagrid.
Sorting not allowed per the tablestyles.
There is a column in the table which is not displayed which controls
the display order. To move a row (or group of rows) in the table
select the rows to move and click the appropriate button next to the datagrid.
One button shifts rows up. A second button shifts rows down.
That much works fine.
After changing the integer values in the displayorder column I reset the
dataview.sort = "displayorder" and the selected rows now appear in
the proper order shifted one row from their previous position.

After shifting the rows I reselect the rows.
My problem is that if I then click the shift button a second time
only the first row selected is shifted and after the shift only that
one shifted row is selected.

Any suggestions?

My shift up Code:
Private Sub cbShiftUp_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles cbShiftUp.Click
Dim dvShift As DataView = dgFleetList.DataSource
Dim drvRow As DataRowView
Dim drvSwap As DataRowView
Dim iPUR As Integer
Dim iSwap As Integer
Dim iR As Integer
Dim iSel As Integer
Dim alChosen As New ArrayList()

'Exit if shifting up is trivial
If dvShift.Count < 2 Then Exit Sub
If dgFleetList.IsSelected(0) Then Exit Sub

'Initialize iPUR (Previous Unselected Row)
iPUR = 0

'Empty the Chosen Row Arraylist
alChosen.Clear()

'Loop through rows
For iR = 1 To dvShift.Count - 1
If dgFleetList.IsSelected(iR) Then
'Swap display position values with iPUR
drvRow = dvShift.Item(iR)
iSwap = drvRow.Item("DisplayOrder")
drvSwap = dvShift.Item(iPUR)
drvRow.Item("DisplayOrder") = drvSwap.Item("DisplayOrder")
alChosen.Add(iR - 1)
drvSwap.Item("DisplayOrder") = iSwap
Else
'Reset iPUR
iPUR = iR
End If
Next

dvShift.Sort = "DisplayOrder"

'Reselect chosen rows
For iR = 0 To alChosen.Count - 1
dgFleetList.Select(alChosen(iR))
Next

End Sub

Nov 21 '05 #1
0 700

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Pete Davis | last post by:
I have written a custom databound grid control that we've been using successfully for months, but one of our developers has just run into a problem that I can't figure out. The code for setting...
4
by: Kris Bethea via DotNetMonster.com | last post by:
Greetings, I have a VB.NET program that I am trying to convert to C# (my office decided that we are going to use C# from now on). I've only been working with C# for about a month now, so this...
2
by: web1110 | last post by:
I created a class derived from a DataGridTextBoxColumn. I have it working through looking at various examples on the net. To update the underlying DataGrid, I had to overload the Edit method...
1
by: Christopher Weaver | last post by:
When I add a row to my DataTable my CurrencyManager doesn't know it's there. I have a ComboBox and a CurrencyManager bound to a DataTable such that a selection within the ComboBox causes all...
10
by: D | last post by:
hi I have a form with 2 datagrids showing related table data in a master / child or order / order details type relationship. I would like to auto select the row in the order details table which...
4
by: Jeremy | last post by:
I have a dataset containing 2 tables. A is the master table, B is a lookup table. There is a combobox bound to B, which updates a value in a FK field in A. my currencymanager is created thus:...
2
by: Rich | last post by:
Hello, I have a datagrid (dgr1) on a form and I'm trying to bind a currencyManager Object (cma) to it and print the current row position. But all I get for cma.Position is 0, 0, 0 for any row...
3
by: Brian Richardson | last post by:
Hi, Please can anyone kindly offer some suggestions as to why the CurrencyManager might not refresh. I am using the CurrencyManager to navigate through a DataView. I am aware that there is...
2
by: Rich | last post by:
Hello, Following an example at http://www.vb-tips.com/dbpages.aspx?IA=DG (by Cor Lightert and Ken Tucker) on binding a dataRelation to a Datagridview for sqlClient, I was able to view rows...
0
by: polocar | last post by:
Hi, I have noticed a strange behaviour of CurrencyManager objects in C# (I use Visual Studio 2005 Professional Edition). Suppose that you have a SQL Server database with 2 tables called "Cities"...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.