Home All Groups Group Topic Archive Search About
Author
29 Jul 2006 2:16 PM
Taoge
DataGridView bind to DataSet which read data from a XML file, when I edit
the cell value and save back, it's ok; but when change the cell value
programmaticlly, the value can not save back to XML file.

Help , please!

Author
29 Jul 2006 2:22 PM
Carl Daniel [VC++ MVP]
Taoge wrote:
> DataGridView bind to DataSet which read data from a XML file, when I
> edit the cell value and save back, it's ok; but when change the cell
> value programmaticlly, the value can not save back to XML file.

Change the cell value programatically by doing what, exactly?  (show some
code).

The value cannot save back to XML, how exactly?  Is an exception being
thrown?  (show some code)

-cd
Author
29 Jul 2006 4:28 PM
Taoge
1.        dgTrack.Rows[Row].Cells["Picture"].Value = Picture;
                dgTrack.Rows[Row].Cells["Longitude"].Value = Longitude;
                dgTrack.Rows[Row].Cells["Latitude"].Value = Latitude;
                dgTrack.Rows[Row].Cells["Radius"].Value = Radius;
                dgTrack.Rows[Row].Cells["Audio1"].Value = objAudio.C1;
                dgTrack.Rows[Row].Cells["Audio2"].Value = objAudio.C2;

                dataSet.WriteXml("setting.xml");
No exception is thrown.

Thanks.

Show quote
"Carl Daniel [VC++ MVP]" <cpdaniel_remove_this_and_nospam@mvps.org.nospam>
wrote in message news:OZJj1pxsGHA.4140@TK2MSFTNGP06.phx.gbl...
> Taoge wrote:
>> DataGridView bind to DataSet which read data from a XML file, when I
>> edit the cell value and save back, it's ok; but when change the cell
>> value programmaticlly, the value can not save back to XML file.
>
> Change the cell value programatically by doing what, exactly?  (show some
> code).
>
> The value cannot save back to XML, how exactly?  Is an exception being
> thrown?  (show some code)
>
> -cd
>
>
Author
29 Jul 2006 5:46 PM
Carl Daniel [VC++ MVP]
Taoge wrote:
>     1.        dgTrack.Rows[Row].Cells["Picture"].Value = Picture;
>                dgTrack.Rows[Row].Cells["Longitude"].Value = Longitude;
>                dgTrack.Rows[Row].Cells["Latitude"].Value = Latitude;
>                dgTrack.Rows[Row].Cells["Radius"].Value = Radius;
>                dgTrack.Rows[Row].Cells["Audio1"].Value = objAudio.C1;
>                dgTrack.Rows[Row].Cells["Audio2"].Value = objAudio.C2;
>
>                dataSet.WriteXml("setting.xml");
> No exception is thrown.

I think you may need to call DataSet.AcceptChanges before WriteXml to make
the edited valus "stick".

-cd
Author
30 Jul 2006 8:25 AM
Taoge
Hi Daniel,

I found that I can't write back XML everytime after I use OpenFileDialog to
find a file, otherwise it's OK.

Thanks!

Show quote
"Carl Daniel [VC++ MVP]" <cpdaniel_remove_this_and_nospam@mvps.org.nospam>
wrote in message news:eNHk5bzsGHA.4140@TK2MSFTNGP06.phx.gbl...
> Taoge wrote:
>>     1.        dgTrack.Rows[Row].Cells["Picture"].Value = Picture;
>>                dgTrack.Rows[Row].Cells["Longitude"].Value = Longitude;
>>                dgTrack.Rows[Row].Cells["Latitude"].Value = Latitude;
>>                dgTrack.Rows[Row].Cells["Radius"].Value = Radius;
>>                dgTrack.Rows[Row].Cells["Audio1"].Value = objAudio.C1;
>>                dgTrack.Rows[Row].Cells["Audio2"].Value = objAudio.C2;
>>
>>                dataSet.WriteXml("setting.xml");
>> No exception is thrown.
>
> I think you may need to call DataSet.AcceptChanges before WriteXml to make
> the edited valus "stick".
>
> -cd
>
>
Author
30 Jul 2006 10:04 AM
Taoge
Hi Carl,

It's because OpenFileDialog changed the current directory.

Thanks!

Show quote
"Carl Daniel [VC++ MVP]" <cpdaniel_remove_this_and_nospam@mvps.org.nospam>
wrote in message news:OZJj1pxsGHA.4140@TK2MSFTNGP06.phx.gbl...
> Taoge wrote:
>> DataGridView bind to DataSet which read data from a XML file, when I
>> edit the cell value and save back, it's ok; but when change the cell
>> value programmaticlly, the value can not save back to XML file.
>
> Change the cell value programatically by doing what, exactly?  (show some
> code).
>
> The value cannot save back to XML, how exactly?  Is an exception being
> thrown?  (show some code)
>
> -cd
>
>

AddThis Social Bookmark Button