CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Threaded View

  1. #1
    Join Date
    Oct 2010
    Posts
    2

    Help with Windows fForm (.net)

    Hello,

    I am new to windows forms so please bear with me!

    Ok, I am trying to make a program for my friends and I who play a card game.
    The basic idea of the program will be to randomize teams and decks to show who is on what team, and what deck they will use.

    So far, this is what I have:

    Code:
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using System.Collections;
    
    namespace WindowsFormsApplication3
    {
        public partial class Form1 : Form
        {
            ArrayList players = new ArrayList();
            ArrayList decks = new ArrayList();
    
            public Form1()
            {
                InitializeComponent();
            }
    
            /***************************************************
             * Add Players
             * ************************************************/
            private void button1_Click(object sender, EventArgs e)
            {
                //Add player Rob to array.
                players.Add("Rob");
            }
    
            private void button2_Click(object sender, EventArgs e)
            {
                //Add player Bryan to array.
                players.Add("Bryan");
            }
    
            private void button4_Click(object sender, EventArgs e)
            {
                //Add player Caryn to array.
                players.Add("Caryn");
            }
    
            private void button3_Click(object sender, EventArgs e)
            {
                //Add player Matt to array.
                players.Add("Matt");
            }
    
            private void button5_Click(object sender, EventArgs e)
            {
                //Add player Chris to array.
                players.Add("Chris");
            }
    
            private void button6_Click(object sender, EventArgs e)
            {
                //Add player Wisto to array.
                players.Add("Wisto");
            }
    
            private void button7_Click(object sender, EventArgs e)
            {
                //Add player Sean to array.
                players.Add("Sean");
            }
    
            /***************************************************
             * Add Decks
             * ************************************************/
            private void button8_Click(object sender, EventArgs e)
            {
                //Add deck Blue/Red to array.
                decks.Add("Blue/Red");
            }
    
            private void button9_Click(object sender, EventArgs e)
            {
                //Add deck Green/Black INFECT to array.
                decks.Add("Green/Black INFECT");
            }
    
            private void button10_Click(object sender, EventArgs e)
            {
                //Add deck Blue to array.
                decks.Add("Blue");
            }
    
            private void button11_Click(object sender, EventArgs e)
            {
                //Add deck Blue/Black to array.
                decks.Add("Blue/Black");
            }
    
            private void button12_Click(object sender, EventArgs e)
            {
                //Add deck Green/Red to array.
                decks.Add("Green/Red");
            }
    
            private void button13_Click(object sender, EventArgs e)
            {
                //Add deck Green/Black to array.
                decks.Add("Green/Black");
            }
    
            private void button14_Click(object sender, EventArgs e)
            {
                //Add deck White to array.
                decks.Add("White");
            }
    
            private void button15_Click(object sender, EventArgs e)
            {
                //Add deck White MYR to array.
                decks.Add("White MYR");
            }
    
            private void button16_Click(object sender, EventArgs e)
            {
                //Add deck ELF to array.
                decks.Add("ELF");
            }
    
            private void button17_Click(object sender, EventArgs e)
            {
                //Add deck Red/Black OLD to array.
                decks.Add("OLD Red/Black");
            }
    
            private void button18_Click(object sender, EventArgs e)
            {
                //Add deck Black OLD to array.
                decks.Add("OLD Black");
            }
    
            private void button19_Click(object sender, EventArgs e)
            {
                //Add deck Blue OLD to array.
                decks.Add("OLD Blue");
            }
    
            private void button20_Click(object sender, EventArgs e)
            {
                //Add deck White OLD to array.
                decks.Add("OLD White");
            }
    
            private void button21_Click(object sender, EventArgs e)
            {
                //Add deck Green/Red OLD to array.
                decks.Add("OLD Green/Red");
            }
    
            private void button22_Click(object sender, EventArgs e)
            {
                //Add deck Green OLD to array.
                decks.Add("OLD Green");
            }
    
            /********************************************************
             * Randomize 
             * for now, just print lists
             * *****************************************************/
    
            private void button25_Click(object sender, EventArgs e)
            {
                for (int i = 0; i < players.Count; i++)
                {
                    string value = players[i] as string;
                    textBox4.Text = value + "\r";
                }
            }
    
            private void button26_Click(object sender, EventArgs e)
            {
                for (int j = 0; j < decks.Count; j++)
                {
                    string value1 = decks[j] as string;
                    textBox3.Text = value1 + "\r";
                }
            }
            
            private void textBox4_TextChanged(object sender, EventArgs e)
            {
    
            }
    
            private void textBox3_TextChanged(object sender, EventArgs e)
            {
    
            }
        }
    }


    Basically, since I am new, I am just trying to add "players" and "decks" to the "players" and "decks" ArrayLists whenever a button is pushed. Than, when I press the "Randomize Names" or "Randomize Decks" buttons, I want to print the ArrayLists into the textBoxes.

    So far, I cannot get anything to print into the Teams textBox and the only thing that prints in the Decks textBox is the last deck button I pushed!

    Any advice or tips would be much appreciated. If you have any questions let me know and I would be happy to send my source code.

    This is just something I'm doing for fun but I am thankful for any help.

    Thanks in advance.
    Last edited by HanneSThEGreaT; May 4th, 2011 at 10:17 AM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured