Sychronize add columns in 2 datagridview controls

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.



dave_skyAsked:
Who is Participating?
 
vb_jonasCommented:
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.
0
 
dave_skyAuthor Commented:
It works great.

Thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.