Solved

Track Changes in Datagrid

Posted on 2004-08-15
6
197 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
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

786 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