One dataset, two datagrid

A

Agnes

I got one dataset, one datatable, but two datagrids.
I use dataview.rowfilter = 'sex ="F" and dataview.rowfilter = 'sex ="M" to
filter the information
and set to two datagrids's datasource = dataview (one is F , other is M)
However , it doesn't work ..
Please help
 
C

Cor Ligthert

Agnes,

Normally that should work, when you use the right quotes.

\\\
dvF.rowfilter = "sex = 'F'"
dvM.rowfilter = "sex = 'M'"
dgF.datasource = dvF
dgM.datasource = dvM
///

That should work, and give a reply if when it does , I get the idea you
seldom do that.

Cor
 
C

CJ Taylor

I've had this same problem with ListBox controls. I had to create 2 copies
of the dataset because it uses the datasets cursor to determine certain
values.

Unless the datagrid makes its own copy of the dataset... Then you can
reference the same one, otherwise, a change in position in the datagrid will
cause a change in position on the underlying dataset.

this includes filtering..
 
A

Agnes

I try your codes, it doesn't work.
It only work for one datagrid in one windowform,
Now, mysolution is One Table, Two datasets, Two datagrids, one Dataset per
one datagrid.
 
C

Cor Ligthert

Agnes,

That was not code that was a snippet

Here a sample code, what I tested, however the same as the snippet.

It gives the longtime regulars from the US and the EU in different datagrid.

\\\It only needs 2 datagrids on a form
Private dtVBreg As DataTable
Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
CreateTables()
Dim dvEU As New DataView(dtVBreg)
Dim dvUS As New DataView(dtVBreg)
dvEU.RowFilter = "Country = 'EU'"
dvUS.RowFilter = "Country = 'US'"
DataGrid1.DataSource = dvEU
DataGrid2.DataSource = dvUS
End Sub


Private Sub CreateTables()
Dim drel As DataRelation

dtVBreg = New DataTable("Persons")
dtVBreg.Columns.Add("Name")
dtVBreg.Columns.Add("Country")
For i As Integer = 0 To 7
dtVBreg.Rows.Add(dtVBreg.NewRow)
Next
dtVBreg.Rows(0).ItemArray = New Object() _
{"Herfried K. Wagner", "EU"}
dtVBreg.Rows(1).ItemArray = New Object() _
{"Ken Tucker", "US"}
dtVBreg.Rows(2).ItemArray = New Object() _
{"CJ Taylor", "US"}
dtVBreg.Rows(3).ItemArray = New Object() _
{"Jay B Harlow", "US"}
dtVBreg.Rows(4).ItemArray = New Object() _
{"Terry Burns", "EU"}
dtVBreg.Rows(5).ItemArray = New Object() _
{"Tom Shelton", "US"}
dtVBreg.Rows(6).ItemArray = New Object() _
{"Cor Ligthert", "EU"}

End Sub

I will be glad to hear if this works or not?

Cor
 
C

CJ Taylor

woot!

Cor Ligthert said:
Agnes,

That was not code that was a snippet

Here a sample code, what I tested, however the same as the snippet.

It gives the longtime regulars from the US and the EU in different datagrid.

\\\It only needs 2 datagrids on a form
Private dtVBreg As DataTable
Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
CreateTables()
Dim dvEU As New DataView(dtVBreg)
Dim dvUS As New DataView(dtVBreg)
dvEU.RowFilter = "Country = 'EU'"
dvUS.RowFilter = "Country = 'US'"
DataGrid1.DataSource = dvEU
DataGrid2.DataSource = dvUS
End Sub


Private Sub CreateTables()
Dim drel As DataRelation

dtVBreg = New DataTable("Persons")
dtVBreg.Columns.Add("Name")
dtVBreg.Columns.Add("Country")
For i As Integer = 0 To 7
dtVBreg.Rows.Add(dtVBreg.NewRow)
Next
dtVBreg.Rows(0).ItemArray = New Object() _
{"Herfried K. Wagner", "EU"}
dtVBreg.Rows(1).ItemArray = New Object() _
{"Ken Tucker", "US"}
dtVBreg.Rows(2).ItemArray = New Object() _
{"CJ Taylor", "US"}
dtVBreg.Rows(3).ItemArray = New Object() _
{"Jay B Harlow", "US"}
dtVBreg.Rows(4).ItemArray = New Object() _
{"Terry Burns", "EU"}
dtVBreg.Rows(5).ItemArray = New Object() _
{"Tom Shelton", "US"}
dtVBreg.Rows(6).ItemArray = New Object() _
{"Cor Ligthert", "EU"}

End Sub

I will be glad to hear if this works or not?

Cor
 
F

Frank

I have a form with 1 dset, 1 dtbl and 2 dviews and 2 dgrids. Works fine. I
don't see why your example shouldn't work. Can't you try it yourself?
Frank
 
C

Cor Ligthert

woot!Do you believe I understand that, with some more words around it maybe I
could, is this indian language?

Cor
 
C

CJ Taylor

Perhaps this is just an American programmer thing.

Or maybe just between my programming cohorts...

Can I get a woot woot!?

I used it because I made the Dataset list.. and that made me happy.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top