Sychronize add columns in 2 datagridview controls

Posted on 2006-04-22
Medium Priority
Last Modified: 2010-04-17
Hi Experts,

In Visual Studio 2005, I am creating a form/subforms to place orders to 4 different suppliers using their specific product numbers.

1. Form "POrders" with child Datagridview, "Datagridview1".
2. "Datagridview1" columns: "ColumnA", "ColumnB", "ColumnC", "ColumnD"
3. "ColumnA" is default column, others are hidden.
4. Never more than one column visable.

Form "POrders" command buttons:
1. Button "Products" opens "ProductsSub" Datagridview (List of Products to pass data to Datagridview1).
2. Buttons "ColumnA", "ColumnB", "ColumnC", "ColumnD" shows columns individually.
4. Again, Never more than one column visable

Form "ProductSub" command buttons:
1. Buttons "ColumnA", "ColumnB", "ColumnC", "ColumnD" shows columns individually.
4. Again, Never more than one column visable

I am trying to synchronize the buttons so they show the same column on both Datagridviews.
Or, have one set of buttons on the "POrders" form that show the same column on both Datagridviews.

I hope this makes sense.

Thanks for your help.

Question by:dave_sky
LVL 12

Accepted Solution

vb_jonas earned 2000 total points
ID: 16517772
Well, You can access the forms from each other, so in the POrders ColumnA-button you could have code to manipulate the grids in the other forms.

Sub ColumnA_Click

Me.DatGridView1.Columns(0).Visible = True
Me.DatGridView1.Columns(1).Visible = False
Me.DatGridView1.Columns(2).Visible = False
Me.DatGridView1.Columns(3).Visible = False

ProductSub.DatGridView1.Columns(0).Visible = True
ProductSub.DatGridView1.Columns(1).Visible = False
ProductSub.DatGridView1.Columns(2).Visible = False
ProductSub.DatGridView1.Columns(3).Visible = False

End Sub

And to sync the data you should bind the grids to te same databindingsource object.

Hope I understood your question correctly.

Author Comment

ID: 16547728
It works great.


Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Simple Linear Regression

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question