Solved

Track Changes in Datagrid

Posted on 2004-08-15
6
200 Views
Last Modified: 2008-03-06
Hi

I have a datagrid on a form which has a table containing XML data bound to it.

I would like to be able to make changes to the XML document when i user has made changes to a cell on the table.  

Please could you tell me what the best way to do this is

Thanks

Matt
0
Comment
Question by:cafferm
  • 3
  • 2
6 Comments
 
LVL 8

Expert Comment

by:razo
ID: 11807399
well if u used a dataset to bind the datagrid from an xmlfile dataset.readxml()
u can use dataset.write(xmlfilename) to update the xmlfile
0
 

Author Comment

by:cafferm
ID: 11807409
the update bit i'm okay with its just catching the data when the user leaves the cell in the datagrid
0
 
LVL 8

Expert Comment

by:razo
ID: 11807422
well if a datagrid is bound to a dataset the dataset automatically updates when a cell value is changed
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 

Author Comment

by:cafferm
ID: 11807444
This is how the datagrid is formed


  Dim xmlFile As String = "..\deid.xml"
  Dim ds1 As New DataSet("DsXML")
  Dim xmlDoc As XmlDocument
  xmlDoc = New XmlDocument()
  xmlDoc.Load(xmlFile)
  Dim DataTable As New Data.DataTable("FileContents")
  Dim l As Integer

      With DataTable.Columns
        .Add("Template_id")
        .Add("Account Name")
      End With

      Dim newIt As ListViewItem
      Dim nodelist As XmlNodeList = xmlDoc.SelectNodes("/deid/deFile")
      Dim node As XmlNode

      l = -1
      For Each node In nodelist
        If node.SelectSingleNode("Template_id").InnerText = "12" Then
          l += 1
          With DataTable.Rows
            .Add(New Object() {})
            .Item(l).Item(0) = node.SelectSingleNode("Template_id").InnerText
            .Item(l).Item(1) = node.SelectSingleNode("Account_Name").InnerText
          End With
          DataTable.AcceptChanges()
        End If
      Next

      Dim GridStyle As DataGridTableStyle = New DataGridTableStyle
      ds1.Tables.Add(DataTable)

      With DataGrid1
        .DataSource = ds1.Tables(0)
        .TableStyles.Add(GridStyle)
      End With

with this the dataset (xml file) doesn't update when you make changes when you change items in the datagrid.  thats why i feel catching the cell changes would work

any ideas?

thanks
0
 
LVL 30

Accepted Solution

by:
Alexandre Simões earned 250 total points
ID: 11808585
Hi...

When I need to accomplish something like this I don't bother catching the events fom the displaying controls, for 2 reasons:
1- Later on, you might (is not already) get sick of the datagrid and change it with another 3rd party grid, and you'll have to recode a lot of lines.
2- A little like above, you'll need to relly everything on the grid control... I allways try to relly the most on the core classes and use the UIControls just to Interface...

This way, again, to accomplish what you want I use the DataTable Events. yes, the datatable have events... and the really ones you need.
This way, for example, the RowChanged event, evaluate what kind of chage occurred, and proceed as you want/need.

This aproach is the one I think's the best... feel free to comment it!

Best regards,
Alex
0
 

Author Comment

by:cafferm
ID: 11849874
Thanks for the guidence!

I used a add handler in the the datagrid filler function to a shared sub where I completed the task via the rowchanged!

Sometimes it just takes a point in the right direction

Thanks alot

Matt
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Variable Event ? 3 36
Creating a route in asp.net webforms 2 32
VB: Convert 2 dates to specific format 24 52
Call windows 10 virtual keyboard from windows forms app 2 50
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question