DataGridView doesn't display anything.
-
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? -
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?at least can you see the column headers? Do you use
AutoGenerateColumns = true
, or defined columns? Calin -
at least can you see the column headers? Do you use
AutoGenerateColumns = true
, or defined columns? Calin -
I cannot see them, the DataGridView is empty. Calin Tatar Where have you found the property "AutoGenerateColumns"?, I couldn't find it.
AutoGenerateColumns
is not browseable in propertygrid. You may use it from code:dataGridView.AutoGenerateColumns = true;
Calin