?
Solved

Track Changes in Datagrid

Posted on 2004-08-15
6
Medium Priority
?
207 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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 1000 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
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…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

649 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