D
Dmitry Bond.
Hello.
Could you please help?
Source: VS2005, .NET 2.0, simple windows application, a number of
*.XML files (sometimes with + *.XSD).
Idea - display DataSet data which was previously stored to XML file
(with DataSet.WriteXml method).
So, the main form has a DataGridView -> BindingSource -> DataSet
objects linked together.
And there is only one button - LoadXml:
private void tbLoadData_Click(object sender, EventArgs e)
{
if (dlgOpen.ShowDialog() != DialogResult.OK) return;
this.dataSet1.ReadXml(dlgOpen.FileName);
string alt_fn = Path.ChangeExtension(dlgOpen.FileName,
".xsd");
if (File.Exists(alt_fn))
this.dataSet1.ReadXmlSchema(alt_fn);
this.bindingSource1.DataMember = this.dataSet1.Tables
[0].TableName;
this.bindingSource1.ResetBindings(true);
this.dataGridView1.Refresh();
this.dataGridView1.Parent.Refresh();
stLab2.Text = string.Format("{0} data rows x {1} columns",
this.dataSet1.Tables[0].Rows.Count,
this.dataSet1.Tables[0].Columns.Count);
}
Of course all XML files has different set of fields (different
schemes) but all of them were stored from .NET applications with
DataSet.WriteXml method (sometimes it also store scheme file near -
but it is optional).
Unfortunately this code does not work. :-\
Question - how to make it working?!
Can you recommend some manuals, guides to read? I mean - guides
exactly about data binding/data displaying. Seems this part in .NET is
extremely tricky and unclear... :-(
--------
Ok. Next problem - performance problem.
I found a way how to display dataset loaded from XML - in the middle
of code listed above I have added this part:
this.dataGridView1.Columns.Clear();
foreach (DataColumn dc in dataSet1.Tables[0].Columns)
{
DataGridViewColumn dgc = new DataGridViewColumn(new
DataGridViewTextBoxCell());
dgc.Name = dc.ColumnName;
dgc.DataPropertyName = dc.ColumnName;
this.dataGridView1.Columns.Add(dgc);
}
So, I recreated columns for DataGridView and now it able to display
data correctly each time I load it from XML.
BUT IS IT EXTREMELY SLOW! I have only 700 rows in DataGridView but it
slowsdowns my computer like there are 700.000 rows (comparing to
normal Win32 applications performance).
So, question is - WHY DataGridView is SO SLOW?
What can I do to make it fast?
What is wrong in my code? In approach I implemented?
Regards,
Dmitry.
Could you please help?
Source: VS2005, .NET 2.0, simple windows application, a number of
*.XML files (sometimes with + *.XSD).
Idea - display DataSet data which was previously stored to XML file
(with DataSet.WriteXml method).
So, the main form has a DataGridView -> BindingSource -> DataSet
objects linked together.
And there is only one button - LoadXml:
private void tbLoadData_Click(object sender, EventArgs e)
{
if (dlgOpen.ShowDialog() != DialogResult.OK) return;
this.dataSet1.ReadXml(dlgOpen.FileName);
string alt_fn = Path.ChangeExtension(dlgOpen.FileName,
".xsd");
if (File.Exists(alt_fn))
this.dataSet1.ReadXmlSchema(alt_fn);
this.bindingSource1.DataMember = this.dataSet1.Tables
[0].TableName;
this.bindingSource1.ResetBindings(true);
this.dataGridView1.Refresh();
this.dataGridView1.Parent.Refresh();
stLab2.Text = string.Format("{0} data rows x {1} columns",
this.dataSet1.Tables[0].Rows.Count,
this.dataSet1.Tables[0].Columns.Count);
}
Of course all XML files has different set of fields (different
schemes) but all of them were stored from .NET applications with
DataSet.WriteXml method (sometimes it also store scheme file near -
but it is optional).
Unfortunately this code does not work. :-\
Question - how to make it working?!
Can you recommend some manuals, guides to read? I mean - guides
exactly about data binding/data displaying. Seems this part in .NET is
extremely tricky and unclear... :-(
--------
Ok. Next problem - performance problem.
I found a way how to display dataset loaded from XML - in the middle
of code listed above I have added this part:
this.dataGridView1.Columns.Clear();
foreach (DataColumn dc in dataSet1.Tables[0].Columns)
{
DataGridViewColumn dgc = new DataGridViewColumn(new
DataGridViewTextBoxCell());
dgc.Name = dc.ColumnName;
dgc.DataPropertyName = dc.ColumnName;
this.dataGridView1.Columns.Add(dgc);
}
So, I recreated columns for DataGridView and now it able to display
data correctly each time I load it from XML.
BUT IS IT EXTREMELY SLOW! I have only 700 rows in DataGridView but it
slowsdowns my computer like there are 700.000 rows (comparing to
normal Win32 applications performance).
So, question is - WHY DataGridView is SO SLOW?
What can I do to make it fast?
What is wrong in my code? In approach I implemented?
Regards,
Dmitry.