Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. How to bind hardcoded DataGridView with DataTable

How to bind hardcoded DataGridView with DataTable

Scheduled Pinned Locked Moved C#
wpfwcfhelptutorial
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Piyush Vaishnav
    wrote on last edited by
    #1

    I have one DataTable and one datagridview. Both are hardcoded. DataTable has been populated and now i want to bind this with DataGridView. DGV.DataSource = datatable; Above code is not working. This code is not giving any error but this code is not populating datagridview. Is there any property for binding Hardcoded DGV. Thanx in Advance.....

    A 1 Reply Last reply
    0
    • P Piyush Vaishnav

      I have one DataTable and one datagridview. Both are hardcoded. DataTable has been populated and now i want to bind this with DataGridView. DGV.DataSource = datatable; Above code is not working. This code is not giving any error but this code is not populating datagridview. Is there any property for binding Hardcoded DGV. Thanx in Advance.....

      A Offline
      A Offline
      AhsanS
      wrote on last edited by
      #2

      // Set up the DataGridView.
      dataGridView1.Dock = DockStyle.Fill;

              // Automatically generate the DataGridView columns.
              dataGridView1.AutoGenerateColumns = true;
      
              // Set up the data source.
              bindingSource1.DataSource = GetData("Select \* From Products");
              dataGridView1.DataSource = bindingSource1;
      
              // Automatically resize the visible rows.
              dataGridView1.AutoSizeRowsMode =
                  DataGridViewAutoSizeRowsMode.DisplayedCellsExceptHeaders;
      
              // Set the DataGridView control's border.
              dataGridView1.BorderStyle = BorderStyle.Fixed3D;
      
              // Put the cells in edit mode when user enters them.
              dataGridView1.EditMode = DataGridViewEditMode.EditOnEnter;
      

      Ahsan Ullah Senior Software Engineer

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups