Hello,
Sorry to post twice in two days...
I have a datagridView component, that uses as its source an XML file.
As the datagridview is changed, I save it back to the XML.
To add a row, I have a textbox I can type into, then a button that calls:
This adds to the datagridview, and also updates the XML file:
This all works fine. However, I have the option to fill the textbox above using an OpenFileDialog box. If I do this, rather than typing a string into the textbox manually, then although the Datagridview is updated, the XML file is not.
What is more, once I have once tried to use the Openfiledialog, even entering tect manually will not cause the XML to be updated uitil I restart the program.
I have compared the hand typed / generated by Openfiledialog strings, and they appear identcal. I found a thread on this forum which sounded similar, but does not appear to help me here.
Does anyone have any ideas?
Cheers
Sorry to post twice in two days...
I have a datagridView component, that uses as its source an XML file.
Code:
Private Sub loadFromXML()
Try
ds.ReadXml(filePath, XmlReadMode.InferSchema)
DataGridView1.DataSource = ds.Tables(0)
Catch ex As Exception
MsgBox("Error: Can't load config.xml")
End Try
End Sub
As the datagridview is changed, I save it back to the XML.
To add a row, I have a textbox I can type into, then a button that calls:
Code:
Private Sub addButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles addButton.Click
Dim curRow = DataGridView1.CurrentCell.RowIndex.ToString()
Dim curTime = DataGridView1.Rows(curRow).Cells(1).Value
If (pathTextBox.TextLength <> 0) Then
If (curTime = "") Then
DataGridView1.Rows.RemoveAt(DataGridView1.CurrentCell.RowIndex.ToString())
End If
Dim newRow As System.Data.DataRow = ds.Tables(0).NewRow
Dim path As String = pathTextBox.Text
Dim array = path.ToArray
newRow.ItemArray = New Object() {path, numberChooser.Value, 0}
ds.Tables(0).Rows.Add(newRow)
DataGridView1.Rows(DataGridView1.RowCount - 1).Cells(0).Selected = True
saveToXML()
End If
End Sub
This adds to the datagridview, and also updates the XML file:
Code:
Private Sub saveToXML()
ds.WriteXml(filePath, XmlWriteMode.IgnoreSchema)
End Sub
This all works fine. However, I have the option to fill the textbox above using an OpenFileDialog box. If I do this, rather than typing a string into the textbox manually, then although the Datagridview is updated, the XML file is not.
What is more, once I have once tried to use the Openfiledialog, even entering tect manually will not cause the XML to be updated uitil I restart the program.
I have compared the hand typed / generated by Openfiledialog strings, and they appear identcal. I found a thread on this forum which sounded similar, but does not appear to help me here.
Does anyone have any ideas?
Cheers