ListButton - Dynamic Buttons

0

I'm making an application where I have several buttons

My intention is to create a list of buttons to make them dynamic. understand why I want to place the numbers shown with information that you have of an XML file already serialized and unrealized

my only question is how can I create the list of buttons?

List<Button> buttons = new List<Button>(); ¿que seguiria?

In my XML file I get the following data

<?xml version="1.0"?>

-<ArrayOfArea xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">


-<Area>

<TOOL>MAK-1234</TOOL>

<AREA>FCH</AREA>

<POOL>Pool 30</POOL>

<TEAM>514</TEAM>

<STATION>1020</STATION>

<OPERATION>Apriete pedal del clutch</OPERATION>

<TORQUE>30</TORQUE>

<TL_NAME>cesar</TL_NAME>

<STATUS>Ok</STATUS>

<STANDBY>1</STANDBY>

<REG_DATE>Monday, June 19, 2017</REG_DATE>

</Area>


-<Area>

<TOOL>SAM-15946</TOOL>

<AREA>FCH</AREA>

<POOL>Pool 30</POOL>

<TEAM>514</TEAM>

<STATION>1020</STATION>

<OPERATION>Apriete pedal del clutch</OPERATION>

<TORQUE>30</TORQUE>

<TL_NAME>Carlos</TL_NAME>

<STATUS>Ok</STATUS>

<STANDBY>1</STANDBY>

<REG_DATE>Monday, June 19, 2017</REG_DATE>

</Area>


-<Area>

<TOOL>NAÑM-46</TOOL>

<AREA>FCH</AREA>

<POOL>Pool 30</POOL>

<TEAM>515</TEAM>

<STATION>1020</STATION>

<OPERATION>Apriete de pedal</OPERATION>

<TORQUE>30</TORQUE>

<TL_NAME>Carmelo</TL_NAME>

<STATUS>OK</STATUS>

<STANDBY>0</STANDBY>

<REG_DATE>Monday, June 19, 2017</REG_DATE>

</Area>

</ArrayOfArea>

on the buttons, what would be "TEAM" and STANDBY with value at 0  I do the different queries to the XML file

So far I have this code, since I have stopped by the question of the list of buttons

//deserealizada
            List<Data.Area> ListOfEquipo = new List<Data.Area>();

            List<Data.Area> ListOfEquposFCHOk = ListOfEquipo.Where(x => x.AREA == "FCH" && x.STANDBY == 0).ToList();

            var TeamFCH = ListOfEquposFCHOk.Select(x => x.TEAM).Distinct().ToList();

            if (true)
            {

            }

            foreach (var team in TeamFCH)
            {

            }
    
asked by Cesar Gutierrez Davalos 23.06.2017 в 19:01
source

1 answer

1

Whereas "TeamFCH" is the list where you store the "Teams" you want to apply to the buttons

List<Button> buttons = new List<Button>(); 

foreach(var item in TeamFCH)
{
   Button newButton = new Button();
   newButton.Number = item; //Estoy tomando "number" como el atributo de tu boton donde ira el numero, seguro lo tienes distinto, posiblemente hasta tengas que hacer un parseo
   buttons.Add(newButton);
}

Once this is finished, you will have your list of buttons.

EDITED: I make this comment for those who see this later, the above resolves the doubt of the question, however it is not optimal that all buttons are created in hard and shown or not according to the number of "teams", the ideal is that they are also created dynamically.

    
answered by 23.06.2017 / 21:01
source