473,775 Members | 2,557 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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">
<!--SABBackgroundSl ideShow 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 2930
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.ReadXml Schema() 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.Rea dXmlSchema("E:\ \ImageControl.x ml");
dataGridView1.D ataSource = 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.WriteXm l() method to write the changes back to the XML file.

For example, you can do something like this:

foreach (DataGridViewRo w row in this.dataGridVi ew1.SelectedRow s)
{
this.dataGridVi ew1.Rows.Remove (row);
}
......
gridDataSet.Wri teXml("E:\\Imag eControl.xml",
XmlWriteMode.Wr iteSchema);
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****@microsof t.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****@microsof t.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
3209
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 datasources. Then at run time when I would bind a dataset to the grid it would display the tablestyle associated with the dataset. How do I do this in VS2005? 2) I do all my databinding to the datagridview at run time, but setup my columns as unbound...
1
4711
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 have changed to 40tude and can't see it in the newly dowloaded messages. It was originally html (tut tut) so maybe it didn't register. I have tried a new xml file and generated a new xsd file from it using xsd.exe and now the xml file produces...
0
1807
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: DataSet1.ReadXml("BIRDS.XML") ' Bind the DataGridView to the DataSet: DataGridView1.DataSource = DataSet1
4
15508
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 edit the information in the grid and when the user has finished, he clicks the "Update" button. Then I update the ID3 information in each MP3 file with the data from the grid. However, if the grid has hundreds of files in it, this can take a...
0
1252
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 to, when I double click on a dataGridView row though, have a second form open with the information displayed in textboxes, etc. Not all of my data is in the dataGridView. From what I can gather, I would use the dataGridView RowEnter event for this,...
0
1216
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 contains a long string, even if I increase height cell, string is only at top....how can I enable "multiline" in a datagridview cell?? Thanks ;)
4
4630
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 datagridview. Do I need to convert the datagridview into something else (dataset?) or should I have put the data into a dataset in the first place. Assuming I can create a 'Data Source' from my data, can you advise me on how to launch a report from a...
1
2362
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(). Is there any way to access that data type directly, since the DataSource field is null when the DataGridView is unbound? 2) Is there any way to add a row which does not have as many columns as the rest of the grid? Basically I have about 10...
1
5366
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 contents. Regardless of whether or not the file exists, the user must be able to modify the data in each cell in the DataGridView, along with being able to add or remove rows. When the Save button is clicked, the contents of the DataGridView must be...
0
9455
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10111
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10054
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9917
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8941
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6719
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5364
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5487
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4021
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.