Another problem. I had this working about two days ago. What am I missing
here. Here is how I write out to the xml file:
Dim dr1 As DataRow = ds.Tables("P1JoyUp").NewRow
dr1("Top") = lblP1JoyUp.Top.ToString
dr1("Left") = lblP1JoyUp.Left.ToString
dr1("Height") = lblP1JoyUp.Height.ToString
dr1("Width") = lblP1JoyUp.Width.ToString
dr1("Visible") = lblP1JoyUp.Visible.ToString
dr1("FontName") = lblP1JoyUp.Font.Name.ToString
dr1("FontSize") = lblP1JoyUp.Font.Size.ToString
dr1("FontBold") = lblP1JoyUp.Font.Bold.ToString
dr1("FontItalic") = lblP1JoyUp.Font.Italic.ToString
Here is what the xml file looks like:
<CPViewer>
<P1JoyUp>
<Top>10</Top>
<Left>10</Left>
<Height>23</Height>
<Width>100</Width>
<Visible>False</Visible>
<ForeColor>Color [White]</ForeColor>
<BackColor>Color [Transparent]</BackColor>
<FontName>Microsoft Sans Serif</FontName>
<FontSize>8.25</FontSize>
<FontBold>False</FontBold>
<FontItalic>False</FontItalic>
</P1JoyUp>
But now when I try to handle the font components individually it underlines
the four font line and says "font.xxxx property is read only. Here is the
code for reading the xml file back in:
If OpenFileDialog1.FileName <> "" Then
Dim ds As New DataSet
ds.ReadXml(OpenFileDialog1.FileName)
lblP1JoyUp.Top = ds.Tables(0).Rows(0).Item(0).ToString
lblP1JoyUp.Left = ds.Tables(0).Rows(0).Item(1).ToString
lblP1JoyUp.Height = ds.Tables(0).Rows(0).Item(2).ToString
lblP1JoyUp.Width = ds.Tables(0).Rows(0).Item(3).ToString
lblP1JoyUp.Visible = ds.Tables(0).Rows(0).Item(4).ToString
lblP1JoyUp.Font.Name = ds.Tables(0).Rows(0).Item(7).ToString
lblP1JoyUp.Font.Size = ds.Tables(0).Rows(0).Item(8).ToString
lblP1JoyUp.Font.Bold = ds.Tables(0).Rows(0).Item(9).ToString
lblP1JoyUp.Font.Italic = ds.Tables(0).Rows(0).Item(10).ToString
lblP1JoyUp.Text = lblP1JoyUp.Name
Like I said, this worked a few days ago but I can't figure it out now. Do I
need to ".ToString" when I am reading back in?
Thanks,
John
Cor Ligthert said:
Hi John,
It is possible with that string to extract it using a regex, a split or an
indexof or any combination of that.
However much easier is just to save the components of the font seperatly in
your XML file
(I showed you it the way you did to make it not that difficult
explaining
it
in a message, although I told that somewhere in a thread of you in this
newsgroup)
blablaFontName = textbox1.font.name.tostring
blablaFondSize = textbox1.font.size.tostring
etc.
Than setting it back is much easier
textbox1.font = new font(blablaFontName, csng(blablaFontSize))
I hope this helps?
Cor