Thanks techgnome, here is what I have right now when calling buttons from my xml file. Please ignore the reference to "labels" as I am doing buttons. I have tried a couple of things here to add color, but have had no success.
Code:Private Sub LoadButtons(ByVal container As Form1, ByVal filename As String) filename = "C:\Temp\Buttons.xml" Dim xmlfile As New XmlDocument xmlfile.Load(filename) Dim labelsroot As XmlElement = DirectCast(xmlfile.SelectSingleNode("buttoncollection"), XmlElement) For Each labelnode As XmlElement In labelsroot.ChildNodes.OfType(Of XmlElement)() Dim location As New Point(CInt(labelnode.Attributes("x").Value), CInt(labelnode.Attributes("y").Value)) Dim size As New Size(CInt(labelnode.Attributes("width").Value), CInt(labelnode.Attributes("height").Value)) Dim lbl As New Label With { .Text = labelnode.Attributes("text").Value, .ForeColor = Color.White, .BackColor = Color.FromArgb(50, 127, 120, 127), '<<<<< this is what I want to get from the xml file .Location = location, .TextAlign = ContentAlignment.MiddleCenter, .Size = size, .Font = New Font("Agency FB", 8, FontStyle.Regular)} container.Controls.Add(lbl) lbl.BringToFront() Next End Sub




Reply With Quote
