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. DataGridView doesn't display anything.

DataGridView doesn't display anything.

Scheduled Pinned Locked Moved C#
question
4 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.
  • A Offline
    A Offline
    AxiliuM
    wrote on last edited by
    #1

    Hello! I have 2 forms. The first has a DataSet with a table("Table1"), the second form has a BindingSource, BindingNavigator, DataGridView; //... Form1 fmMain=new Form1; //...Button click Form2 fmSecond=new Form2(); fm.ShowDialog(fmMain) //... private void Form2_Load(object sender, EventArgs e) { BindingSource.DataSource = ((Form1)this.Parent).DataSet; BindingSource.DataMember = "Table"; DataGridView.DataSource=BindingSource; BindingNavigator.BindingSource=BindingSource; } BindingNavigator shows that there are 100 rows and the position=1, but DataGridView doesn't display anything. But this code works: //... Form1 fmMain=new Form1; //...Button click Form2 fmSecond=new Form2(); fm.ShowDialog(fmMain) //... private void Form2_Load(object sender, EventArgs e) { DataGridView dt = new DataGridView(); BindingSource.DataSource = ((Form1)this.Parent).DataSet; BindingSource.DataMember = "Table"; dt.DataSource=BindingSource; dt.Parent = this; BindingNavigator.BindingSource=BindingSource; } Does anybody have some ideeas?

    C 1 Reply Last reply
    0
    • A AxiliuM

      Hello! I have 2 forms. The first has a DataSet with a table("Table1"), the second form has a BindingSource, BindingNavigator, DataGridView; //... Form1 fmMain=new Form1; //...Button click Form2 fmSecond=new Form2(); fm.ShowDialog(fmMain) //... private void Form2_Load(object sender, EventArgs e) { BindingSource.DataSource = ((Form1)this.Parent).DataSet; BindingSource.DataMember = "Table"; DataGridView.DataSource=BindingSource; BindingNavigator.BindingSource=BindingSource; } BindingNavigator shows that there are 100 rows and the position=1, but DataGridView doesn't display anything. But this code works: //... Form1 fmMain=new Form1; //...Button click Form2 fmSecond=new Form2(); fm.ShowDialog(fmMain) //... private void Form2_Load(object sender, EventArgs e) { DataGridView dt = new DataGridView(); BindingSource.DataSource = ((Form1)this.Parent).DataSet; BindingSource.DataMember = "Table"; dt.DataSource=BindingSource; dt.Parent = this; BindingNavigator.BindingSource=BindingSource; } Does anybody have some ideeas?

      C Offline
      C Offline
      Calin Tatar
      wrote on last edited by
      #2

      at least can you see the column headers? Do you use AutoGenerateColumns = true, or defined columns? Calin

      A 1 Reply Last reply
      0
      • C Calin Tatar

        at least can you see the column headers? Do you use AutoGenerateColumns = true, or defined columns? Calin

        A Offline
        A Offline
        AxiliuM
        wrote on last edited by
        #3

        I cannot see them, the DataGridView is empty. Calin Tatar Where have you found the property "AutoGenerateColumns"?, I couldn't find it.

        C 1 Reply Last reply
        0
        • A AxiliuM

          I cannot see them, the DataGridView is empty. Calin Tatar Where have you found the property "AutoGenerateColumns"?, I couldn't find it.

          C Offline
          C Offline
          Calin Tatar
          wrote on last edited by
          #4

          AutoGenerateColumns is not browseable in propertygrid. You may use it from code:

          dataGridView.AutoGenerateColumns = true;

          Calin

          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