mardi 21 avril 2015

How to pass a var list to another winform c#

Let's say I have this code. How can I pass smallGroups to UpdatePlayer form. I need to be able to use the data generated to the var list and use it in UpdatePlayer to populate combobox? Could someone help me please

    public class GroupsPlayers
    {
        public string GroupID;
        public string GroupName;
    }

public void Groups() {
    var smallGroups = new List<GroupsPlayers>();


    while(rd.Read())
    {
        var currentPlayer = new GroupsPlayers() {
            GroupID = rd["GroupID"],
            GroupName = rd["GroupName"]
        };

        smallGroups.Add(currentPlayer);
    }

    string msgBoxMsg = string.Format("There are {0} groups with fewer than 3 players. Do you want to add new players to the group?", smallGroups.Count);

    MessageBoxResult userResponse = MessageBox.Show(msgBoxMsg, "Groups Manager", MessageBoxButtons.YesNo);

    if(userResponse == DialogResult.Yes)
    {
        UpdatePlayer frmPlayers = new UpdatePlayer(this, smallGroups);
    }
}

Aucun commentaire:

Enregistrer un commentaire