473,395 Members | 1,456 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Questions on DataGridView and XML files

I have an application that populates a DataGridView control with an XML. file.

1. How do I set up the process so the user initally sees just the headers -- no records.

I have the DataGridView properties set to allow the user to edit data but not add or delete (which
will be down in the program). However when I execute the ReadXML method one emtpy row is shown.
The starter XML contains:
<?xml version="1.0" encoding="utf-8"?>
<DataSet1 xmlns="http://www.tempuri.org/DataSet1.xsd">
<!--SABBackgroundSlideShow Image Conrol-->
<Images>
<Sequence></Sequence>
<Name></Name>
<Location></Location>
<Style></Style>
<Duration></Duration>
</Images>
</DataSet1>

If I delete the entries under <Imagesthen ReadXML throws an error.

2. How do I map a row selected in the DataGridView control to the DataSet so I can delete it?
Nov 14 '08 #1
2 2912
Hello Stewart,

Thank you for using Microsoft Managed Newsgroup Service. My name is Zhi-Xin
Ye, it's my pleasure to work with you on this issue.

- 1. How do I set up the process so the user initally sees just the
headers -- no records.

You can call the DataSet.ReadXmlSchema() method to read the XML schema to
DataSet, and assign this DataSet to the DataGridView as data source.

For example, you can do something like this:

gridDataSet = new DataSet();
gridDataSet.ReadXmlSchema("E:\\ImageControl.xml");
dataGridView1.DataSource = gridDataSet;

- 2. How do I map a row selected in the DataGridView control to the
DataSet so I can delete it?

You can delete the selected rows from the DataGridView directly, and call
the DataSet.WriteXml() method to write the changes back to the XML file.

For example, you can do something like this:

foreach (DataGridViewRow row in this.dataGridView1.SelectedRows)
{
this.dataGridView1.Rows.Remove(row);
}
......
gridDataSet.WriteXml("E:\\ImageControl.xml",
XmlWriteMode.WriteSchema);
If you have any questions or concerns, please don't hesitate to let me know.

Sincerely,
Zhi-Xin Ye
Microsoft Managed Newsgroup Support Team

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subs...#notifications.

Note: MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 2 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions. Issues of this
nature are best handled working with a dedicated Microsoft Support Engineer
by contacting Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/en-us/subs.../aa948874.aspx
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 17 '08 #2
Hello Stewart,

How about this issue now? If you still need any help or have any concern,
please feel free to feedback, thanks.

Sincerely,
Zhi-Xin Ye
Microsoft Managed Newsgroup Support Team

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.

This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 20 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Brian | last post by:
I've got a couple questions on the new Datagridview control in VS2005. 1) In the old datagrid control at design time I was able to add multiple tablestyles with columns from different...
1
by: mark carew | last post by:
Hi, Problem - An extra column to the left (even with row headers disabled) ---------------------------------------------------------- Apologies if this posting is already in the newsgroup; but...
0
by: David Mayerovitch | last post by:
As an exercise in learning Visual Basic 2005, I am putting together a simple XML editor. I place on the form the objects DataGridView1 and DataSet1. ' Read an XML file into DataSet1:...
4
by: Terry Olsen | last post by:
How can i tell if a row in my DataGridView has been edited? I'm loading a DataTable with ID3 information from MP3 files and using that as the datasource for the DataGridView. I'm letting the user...
0
by: CSharpie1000 | last post by:
I am sorry for the broadness of this question, but I litterally can't get anywhere with this. I have a dataGridView that loads data from an Access 2007 Database. This works fine. I would like...
0
by: Alcibiade | last post by:
Hi, I have 2 questions: 1)if width datagridview is shorter than form witdh, user will see horizontal scrollbar to see all grid.How can I adapt width form to width datagridview? 2) If a cell...
4
by: Peter Forman | last post by:
I have a windows form that contains a datagridview containing manipulated data from various sources (numerous sql servers + xml files). I now need to create a report from the data in the...
1
by: stumorgan | last post by:
I have a couple questions regarding the DataGridView object... 1) What is the underlying data type that the DataGridView uses if you are using it unbound and do for instance dgv.Columns.Add(). ...
1
by: Avedo | last post by:
Hello! I have a form application with a DataGridView, and an Save/Delete and Cancel button. When the application is opened, it is supplied an XML file that may or may not exist, and display the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.