Sychronize add columns in 2 datagridview controls

Posted on 2006-04-22
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

    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

    It works great.


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Course: HTML5 Specialist

    HTML5 development skills are critical to all developers. HTML5 is the foundation to almost any development process. That's why business, design studios, development shops and other organizations need HTML5 developers. Get your foot in the door as a HTML5 specialist.

    Suggested Solutions

    Here we come across an interesting topic of coding guidelines while designing automation test scripts. The scope of this article will not be limited to QTP but to an overall extent of using VB Scripting for automation projects. Introduction Now…
    This is an explanation of a simple data model to help parse a JSON feed
    Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
    In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

    758 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

    Need Help in Real-Time?

    Connect with top rated Experts

    7 Experts available now in Live!

    Get 1:1 Help Now