ElPicklers Assosciate
ElPicklers Assosciate
CC#
Created by ElPicklers Assosciate on 11/16/2023 in #help
Card Game
please.
7 replies
CC#
Created by ElPicklers Assosciate on 11/16/2023 in #help
Card Game
help.
7 replies
CC#
Created by ElPicklers Assosciate on 11/16/2023 in #help
Card Game
No description
7 replies
CC#
Created by ElPicklers Assosciate on 11/16/2023 in #help
Card Game
this is what i have but when i run it i get an error saying
7 replies
CC#
Created by ElPicklers Assosciate on 11/16/2023 in #help
Card Game
public void AssignCardsToButtons() { for (int i = 2; i < Math.Min(deck.Count + 2, 9); i++) { // Assuming the CardX methods create dynamic buttons GetType().GetMethod($"Card{i}").Invoke(this, null); int cardIndex = i - 2; if (cardIndex >= 0 && cardIndex < deck.Count) { string newdir = @"(where the cards are stored)"; newdir = Path.Combine(newdir, $"{deck[cardIndex].Value.ToLower()}of{deck[cardIndex].Suit.ToLower()}.png"); var dynamicButton = Controls.OfType<Button>().Last(); // Assuming the dynamic button is the last added button dynamicButton.Click += (sender, e) => MessageBox.Show($"Clicked: {deck[cardIndex]}"); dynamicButton.Image?.Dispose(); dynamicButton.Image = Image.FromStream(new MemoryStream(File.ReadAllBytes(newdir)), true, false); } else { MessageBox.Show($"Not enough cards in the deck for button {i}"); } } }
7 replies