Results 1 to 3 of 3

Thread: Programmatically build DataGridView with BindingSource

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2012
    Posts
    7

    Programmatically build DataGridView with BindingSource

    I've got a form with a DataGridView bound to a BindingSource on the form. I want to specify the columns and the column bindings at run time. I grid shows as many rows as there are in the DataSet but the columns don't show any values.

    I'm doing the following.
    HTML Code:
    Dim testForm As New TestForm()
    testForm.TestGrid.Columns.Add("Code", "Code")
    testForm.TestGrid.Columns.Add("Name", "Name")
    testForm.TestGrid.Columns.Add("Type", "Type")
    testForm.TestBindingSource.DataSource = productDataSet
    productDataSet is a typed Dataset.

    Thanks for your help.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,347

    Re: Programmatically build DataGridView with BindingSource

    You have to set the DataPropertyName of the column to tell it which column/property of the data source to bind to.

  3. #3

    Thread Starter
    New Member
    Join Date
    May 2012
    Posts
    7

    Re: Programmatically build DataGridView with BindingSource

    Thanks. That worked.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width