Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

2 dataviews acting like one 1

Status
Not open for further replies.

tfstom

Programmer
Sep 28, 2002
190
US
I have 2 combo boxes (cbxround1 and cbxround2) which will have the same data and am using 2 dataviews (dvROUND1 and dvROUND2) to look at them.

The problem is that when I change the selected item in one, it also changes the selected item in the second box. I don't want to do that. I want the 2nd box to look at the next item (if cbxround1.selectedIndex = 1, I want cbxround2.selectedIndex = 2). But when I change cbxround2.selectedIndex = cbxround1.selectedIndex + 1, cbxround1 gets changed also????

They are different views so why does this happen?

Code:
        Dim daROUND As New OleDb.OleDbDataAdapter(sqlROUND, cnWWR)
        Dim dsROUND As New DataSet()
        daROUND.Fill(dsROUND, strROUND)
        Dim dvROUND1 As DataView = dsROUND.Tables(strROUND).DefaultView
        Dim dvROUND2 As DataView = dsROUND.Tables(strROUND).DefaultView
        cbxRound1.DataSource = dvROUND1
        cbxRound1.DisplayMember = "DESCRIPTION"
        cbxRound1.ValueMember = "ROUNDNUM"
        cbxRound2.DataSource = dvROUND2
        cbxRound2.DisplayMember = "DESCRIPTION"
        cbxRound2.ValueMember = "ROUNDNUM"
        FirstRoundIndex = cbxRound1.SelectedIndex
        SecondRoundIndex = FirstRoundIndex + 1
        cbxRound2.SelectedIndex = SecondRoundIndex


Thanks,

Tom.
 
Try using a copy of a table in the first dataview, rather than using it again and see if it makes the difference.
Code:
Dim dvROUND1 As DataView = dsROUND.Tables(strROUND).DefaultView
'Dim dvROUND2 As DataView = dsROUND.Tables(strROUND).DefaultView
Dim dvROUND2 As DataView = dvROUND1.Table.Copy().DefaultView
 
That worked.

The question is, why didn't the other.

We have 2 separate views into a database. Why would changing one combo box, which is looking at one view, also change the other combobox, which is using a completely different view?

Thanks,

Tom
 
because they're both using the same CurrencyManager associated with the datatable (basically the selected row from the table is being changed which causes both comboboxes to update their values to the selected row)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top