473,395 Members | 1,653 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,395 software developers and data experts.

Multiple datagridviews same form

I am using VB within VS 2005. How can I have multiple datagridviews on the
same form pulling from the same table? e.g. I want to see all clients from
New York in one view and all clients from LA in another view on the same
form. I've set up a parameterized tableadapter and pass it the city. How can
I load the two views in VB code when the form loads?

Thanks,

Tom
Sep 29 '06 #1
3 4446

Hi Tom,

Pull all of your data into a dataset and then just create two dataviews from
your dataset. Then assign each dataview to a separate grid.

ex:

.....code to load dataset

Dim dv1 As DataView = New DataView(ds.Table ("MyTableName"), "city=NY", "",
DataViewRowState.CurrentRows)

Dim dv2 As DataView = New DataView(ds.Table ("MyTableName"), "city=LA", "",
DataViewRowState.CurrentRows)

--
Franklin M. Gauer III
Applications Development Manager
Integrated Companies, Inc.
"TomH" wrote:
I am using VB within VS 2005. How can I have multiple datagridviews on the
same form pulling from the same table? e.g. I want to see all clients from
New York in one view and all clients from LA in another view on the same
form. I've set up a parameterized tableadapter and pass it the city. How can
I load the two views in VB code when the form loads?

Thanks,

Tom
Sep 29 '06 #2

....or (thinking more in terms of performance) just call your table adapter
query twice - once for LA and once for NY - assigning the results to a
different dataset (i.e. create two datasets in your client application). Then
assign each dataset to a different grid.

You can essentially have as many datasets as you want in your app:

ex:

Dim ds as new system.data.dataset
Dim ds2 as new system.data.dataset
Dim ds3 as new system.data.dataset

....and just fill each one of them up with different calls to your table
adapter.

--
Franklin M. Gauer III
Applications Development Manager
Integrated Companies, Inc.
"Franklin M. Gauer III" wrote:
>
Hi Tom,

Pull all of your data into a dataset and then just create two dataviews from
your dataset. Then assign each dataview to a separate grid.

ex:

....code to load dataset

Dim dv1 As DataView = New DataView(ds.Table ("MyTableName"), "city=NY", "",
DataViewRowState.CurrentRows)

Dim dv2 As DataView = New DataView(ds.Table ("MyTableName"), "city=LA", "",
DataViewRowState.CurrentRows)

--
Franklin M. Gauer III
Applications Development Manager
Integrated Companies, Inc.
"TomH" wrote:
I am using VB within VS 2005. How can I have multiple datagridviews on the
same form pulling from the same table? e.g. I want to see all clients from
New York in one view and all clients from LA in another view on the same
form. I've set up a parameterized tableadapter and pass it the city. How can
I load the two views in VB code when the form loads?

Thanks,

Tom
Sep 29 '06 #3
Thanks for the responses. Creating multiple datasets works. However, I would
prefer to create my datasets and dataviews on the form at design time, rather
than create them on the fly at runtime. It also appears multiple datasets
will require me to create duplicate queries (in seperate tableadapters),
resulting in more difficult maintenance if the query changes.

Thanks again,

Tom

"Franklin M. Gauer III" wrote:
>
...or (thinking more in terms of performance) just call your table adapter
query twice - once for LA and once for NY - assigning the results to a
different dataset (i.e. create two datasets in your client application). Then
assign each dataset to a different grid.

You can essentially have as many datasets as you want in your app:

ex:

Dim ds as new system.data.dataset
Dim ds2 as new system.data.dataset
Dim ds3 as new system.data.dataset

...and just fill each one of them up with different calls to your table
adapter.

--
Franklin M. Gauer III
Applications Development Manager
Integrated Companies, Inc.
"Franklin M. Gauer III" wrote:

Hi Tom,

Pull all of your data into a dataset and then just create two dataviews from
your dataset. Then assign each dataview to a separate grid.

ex:

....code to load dataset

Dim dv1 As DataView = New DataView(ds.Table ("MyTableName"), "city=NY", "",
DataViewRowState.CurrentRows)

Dim dv2 As DataView = New DataView(ds.Table ("MyTableName"), "city=LA", "",
DataViewRowState.CurrentRows)

--
Franklin M. Gauer III
Applications Development Manager
Integrated Companies, Inc.
"TomH" wrote:
I am using VB within VS 2005. How can I have multiple datagridviews on the
same form pulling from the same table? e.g. I want to see all clients from
New York in one view and all clients from LA in another view on the same
form. I've set up a parameterized tableadapter and pass it the city. How can
I load the two views in VB code when the form loads?
>
Thanks,
>
Tom
Oct 2 '06 #4

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

Similar topics

2
by: jpenn44 | last post by:
I have multiple datagridviews on one form. I am allowing editing in the grid, and am performing error checking. I am validating the data, if it isn't valid, I am cancelling any other events...
2
by: martin1 | last post by:
all, is it possible to have more than one DataGridView within one Form? I try to bind dataset to different DatagridViews. Thanks
0
by: hangdee | last post by:
I want to create 2 same structure datagridview in a form. But when I set same column name in datagridview, it prompts that same name is used by another component. So is it true that we cannot...
0
by: Bruce HS | last post by:
I use DataGridViews for the detail part of lots of Master/Detail entry forms. This time I need the user to see a dozen fields all at once for each detail record, and the best way to do this would...
7
by: =?Utf-8?B?TG9zdEluTUQ=?= | last post by:
Hi All :) I'm converting VB6 using True DBGrid Pro 8.0 to VB2005 using DataGridView. True DBGrid has a MultipleLines property that controls whether individual records span multiple lines. Is...
10
by: =?Utf-8?B?UGV0ZXI=?= | last post by:
I'm using this coding to get 2 resultsets thru datareader and then load them into 2 datatables and bind the datatables to datagridviews. But sdrGrid.NextResult() is returning false for some...
0
by: Chris | last post by:
I have two datagridviews on a form that are linked via a datarelation. I am using: "foreach ( DataGridViewRow tripRow in scenario_TripsDataGridView.Rows )" to loop thru all the rows in the...
1
by: Stefan Hoffmann | last post by:
hi @ll, VS2008, .Net 2.0 (migrated source from VS2003) I have a form with three DataGrids (not DataGridViews). When I set the CaptionFont in the designer, it is not correctly persisted. It...
6
by: Gun Slinger | last post by:
Hi guys, I have a quick question which i have pondered for a little while. I'm not sure if its even a good idea (so maybe advice on whether or not to do it would be helpful as well). I want to...
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?
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.