Hello,

I am trying to create a form in C# that will get its buttons configured from a xml file. Here is a sample of my xml file:

<?xml version="1.0" ?>
- <LauncherConfig>
- <GeneralOptions>
<Name>FORM_NAME</Name>
<BackgrounColor>Gray</BackgrounColor>
<PercentOpaque>50</PercentOpaque>
<StayOnTop>True</StayOnTop>
<Orientation>Horizontal</Orientation>
</GeneralOptions>
- <Group1>
<GroupName_Lable>GPS/Mapping</GroupName_Lable>
<Horizontal_Number_Rows>1</Horizontal_Number_Rows>
<Verticle_Number_Columns>1</Verticle_Number_Columns>
- <Button1>
<ButtonLabel>OZI</ButtonLabel>
<UnselectedButtonTextColor>FFFFFF</UnselectedButtonTextColor>
<SelectedButtonTextColor>000000</SelectedButtonTextColor>
<UnselectedButtonColor>CC0000</UnselectedButtonColor>
<SelectedButtonColor>333399</SelectedButtonColor>
<ApplicationToLaunch>"C:\Program Files\OziExplorer\OziExp.exe"</ApplicationToLaunch>
<ButtonSizeWidth>55</ButtonSizeWidth>
<ButtonSizeHeight>31</ButtonSizeHeight>
</Button1>

What I would like to do is on form run, check the xml for the number of buttons to create, get their size, color etc and structure the form around those buttons. I am trying to group the buttons with a label as well.

Another difficult (for me at least) is to change the orientation of the form to be either vertical or horizontal based on the xml config.

If someone can get me started with the auto-creation of the buttons based on the xml sippet, I would greatly appreciate it. I don't have a problem creating the form manually using VS2005 designer, however the on-the fly creation is giving me headaches.

Thanks in advance for any help

Creating controls in runtime is very easy task, just use XMLReader class in System.XML namespace to read your xml file and define your button properties and then create button control with specified properties.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.