Click here to Skip to main content
16,004,882 members
Home / Discussions / C#
   

C#

 
GeneralRe: How to refresh my Form Pin
gizmokaka16-Oct-07 3:59
gizmokaka16-Oct-07 3:59 
AnswerRe: How to refresh my Form Pin
Martin#16-Oct-07 4:14
Martin#16-Oct-07 4:14 
GeneralRe: How to refresh my Form Pin
gizmokaka16-Oct-07 9:29
gizmokaka16-Oct-07 9:29 
GeneralRe: How to refresh my Form Pin
gizmokaka17-Oct-07 7:43
gizmokaka17-Oct-07 7:43 
GeneralRe: How to refresh my Form Pin
Martin#17-Oct-07 20:26
Martin#17-Oct-07 20:26 
QuestionHelp needed with a complicated application Pin
Lucy16-Oct-07 0:58
Lucy16-Oct-07 0:58 
AnswerRe: Help needed with a complicated application Pin
DavidNohejl16-Oct-07 1:08
DavidNohejl16-Oct-07 1:08 
GeneralRe: Help needed with a complicated application Pin
Lucy16-Oct-07 1:34
Lucy16-Oct-07 1:34 
Sorry I am very new to C# and I am trying alter a console application example from a book to a windows form to test my skills and how much I have learnt. I think I haven't learnt to much and I have taken on a huge task.

I have this method PlayGame()

        public void PlayGame()<br />
        {<br />
            Player[] players = new Player[1];<br />
<br />
            for (int p = 0; p < players.Length; p++)<br />
            {<br />
                string playerName = listBox1.SelectedItem.ToString();<br />
                players[p] = new Player(playerName);<br />
            }<br />
<br />
            if (players == null)<br />
                return;<br />
<br />
            for (int p = 0; p < players.Length; p++)<br />
            {<br />
                for (int c = 0; c < 7; c++)<br />
                {<br />
                    players[p].PlayHand.Add(playDeck.GetCard(currentCard++));<br />
                }<br />
            }<br />
<br />
            //int currentPlayer;<br />
            Card playCard = playDeck.GetCard(currentCard++);<br />
            discardedCards.Add(playCard);<br />
<br />
            for (currentPlayer = 0; currentPlayer < players.Length; currentPlayer++)<br />
            {<br />
                label1.Text = players[currentPlayer].Name + "'s turn.";<br />
                labelHiden.Text = Convert.ToString(currentPlayer);<br />
                label2hiden.Text = Convert.ToString(players[currentPlayer]);<br />
                foreach (Card card in players[currentPlayer].PlayHand)<br />
                {<br />
                    listBox2.Items.Add(Convert.ToString(card));<br />
                    //richTextBox1.Text = Convert.ToString(card);<br />
                }<br />
                label3.Text = "Card in play: " + playCard;<br />
<br />
                if (discardedCards.Contains(playCard))<br />
                {<br />
                    discardedCards.Remove(playCard);<br />
                }<br />
                players[currentPlayer].PlayHand.Add(playCard);<br />
                label1.Text = "Drawn: " + playCard;<br />
<br />
                label1.Text = "New Hand:";<br />
<br />
                for (int i = 0; i < players[currentPlayer].PlayHand.Count; i++)<br />
                {<br />
                    listBox2.Items.Add(i + 1 + ": " + players[currentPlayer].PlayHand[i]);<br />
                    //richTextBox1.Text = i + 1 + ": " + players[currentPlayer].PlayHand[i];<br />
                }<br />
                label3.Text = "Choose card to discard:";<br />
            }<br />
            current = playCard;<br />
            //return;<br />
            <br />
        }


I only want this section of code to execute if a button is clicked:

<br />
                if (discardedCards.Contains(playCard))<br />
                {<br />
                    discardedCards.Remove(playCard);<br />
                }<br />
                players[currentPlayer].PlayHand.Add(playCard);<br />
                label1.Text = "Drawn: " + playCard;<br />


I was wondering if there was a way of breaking this loop to wait if the button is clicked.

Lucy
GeneralRe: Help needed with a complicated application Pin
Christian Graus16-Oct-07 1:39
protectorChristian Graus16-Oct-07 1:39 
GeneralRe: Help needed with a complicated application Pin
Lucy16-Oct-07 1:49
Lucy16-Oct-07 1:49 
AnswerRe: Help needed with a complicated application Pin
Christian Graus16-Oct-07 1:24
protectorChristian Graus16-Oct-07 1:24 
QuestionHow to convert SqlDataReader into a user defined class? Pin
hogan.smith16-Oct-07 0:26
hogan.smith16-Oct-07 0:26 
AnswerRe: How to convert SqlDataReader into a user defined class? Pin
Andrei Ungureanu16-Oct-07 0:29
Andrei Ungureanu16-Oct-07 0:29 
GeneralRe: How to convert SqlDataReader into a user defined class? Pin
hogan.smith16-Oct-07 0:36
hogan.smith16-Oct-07 0:36 
GeneralRe: How to convert SqlDataReader into a user defined class? Pin
Andrei Ungureanu16-Oct-07 0:42
Andrei Ungureanu16-Oct-07 0:42 
GeneralRe: How to convert SqlDataReader into a user defined class? Pin
hogan.smith16-Oct-07 0:46
hogan.smith16-Oct-07 0:46 
Question[Message Deleted] Pin
Trustapple16-Oct-07 0:02
Trustapple16-Oct-07 0:02 
AnswerRe: seminar Pin
Christian Graus16-Oct-07 0:17
protectorChristian Graus16-Oct-07 0:17 
GeneralRe: seminar Pin
Trustapple16-Oct-07 0:21
Trustapple16-Oct-07 0:21 
GeneralRe: seminar Pin
DavidNohejl16-Oct-07 1:15
DavidNohejl16-Oct-07 1:15 
AnswerRe: seminar Pin
Pete O'Hanlon16-Oct-07 0:27
mvePete O'Hanlon16-Oct-07 0:27 
GeneralRe: seminar Pin
Trustapple16-Oct-07 0:43
Trustapple16-Oct-07 0:43 
QuestionC++ Pin
SVb.net15-Oct-07 23:40
SVb.net15-Oct-07 23:40 
AnswerRe: C++ Pin
Christian Graus15-Oct-07 23:56
protectorChristian Graus15-Oct-07 23:56 
Questionassembly Pin
SVb.net15-Oct-07 23:27
SVb.net15-Oct-07 23:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.