Question
I was hoping someone could help figure out a way to resize the Bingo Card that gets generated from the given code. I have tried
I was hoping someone could help figure out a way to resize the Bingo Card that gets generated from the given code. I have tried to mess with it but It completely screws things up. Also is there a way to have the actual form window be maximized once I run the program?
In the pictures I provided, you can see what it looks like when I run the program. Then when I maximize it, and generate the board, you can see how its cut off
// Creates the Bingo Card for Play private void createCard() { // Dynamically Creates 25 buttons on a Bingo Board // Create and Add the buttons to the form
Size size = new Size(75, 75); // if (gameCount > 0) size = new Size(40,40); Point loc = new Point(0, 0); int topMargin = 60;
int x; int y;
// Draw Column indexes y = 0; DrawColumnLabels();
x = xcardUpperLeft; y = ycardUpperLeft;
// Draw top line for card drawHorizBar(x, y, BINGOCARDSIZE); y = y + barWidth;
// The board is treated like a 5x5 array drawVertBar(x, y); for (int row = 0; row
if (row == BINGOCARDSIZE / 2 && col == BINGOCARDSIZE / 2) { newButton[row, col].Font = new Font("Arial", 10, FontStyle.Bold); newButton[row, col].Text = "Free Space"; newButton[row, col].BackColor = System.Drawing.Color.Orange; newButton[row, col].Enabled = false; } else { newButton[row, col].Font = new Font("Arial", 24, FontStyle.Bold); newButton[row, col].Enabled = true; newButton[row, col].Text = RNGObj.getRandomValue(bingoLetters[col]).ToString(); } // end if newButton[row, col].Name = "btn" + row.ToString() + col.ToString();
// Associates the same event handler with each of the buttons generated newButton[row, col].Click += new EventHandler(Button_Click);
// Add button to the form pnlCard.Controls.Add(newButton[row, col]);
// Draw vertical delimiter x += cardCellWidth + padding; if (row == 0) drawVertBar(x - 5, y); } // end for col // One row now complete
// Draw bottom square delimiter if square complete x = xcardUpperLeft - 20; y = y + cardCellHeight + padding; drawHorizBar(x + 25, y - 10, BINGOCARDSIZE - 10); } // end for row
// Draw column indices at bottom of card y += barWidth - 1; DrawColumnLabels(); Globals.UsedNumbersObj.reset(); } // end createBoard
// Draws column indexes at top and bottom of card private void DrawColumnLabels() { Label lblColID = new Label(); lblColID.Font = new System.Drawing.Font("Microsoft Sans Serif", (float)24.0, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, 0); lblColID.ForeColor = System.Drawing.Color.Orange; lblColID.Location = new System.Drawing.Point(cardCellWidth, 0); lblColID.Name = "lblColIDBINGO"; lblColID.Size = new System.Drawing.Size(570, 32); lblColID.TabIndex = 0; lblColID.Text = "B I N G O"; pnlCard.Controls.Add(lblColID); lblColID.Visible = true; lblColID.CreateControl(); lblColID.Show(); } // end drawColumnLabels
// Draw the dark horizontal bar private void drawHorizBar(int x, int y, int cardSize) { int currentx; currentx = x;
Label lblHorizBar = new Label(); lblHorizBar.BackColor = System.Drawing.SystemColors.ControlText; lblHorizBar.Location = new System.Drawing.Point(currentx, y); lblHorizBar.Name = "lblHorizBar"; lblHorizBar.Size = new System.Drawing.Size((cardCellWidth + padding - 1) * BINGOCARDSIZE, barWidth); lblHorizBar.TabIndex = 20; pnlCard.Controls.Add(lblHorizBar); lblHorizBar.Visible = true; lblHorizBar.CreateControl(); lblHorizBar.Show(); currentx = currentx + cardCellWidth; } // end drawHorizBar
// Draw dark vertical bar private void drawVertBar(int x, int y) { Label lblVertBar = new Label(); lblVertBar.BackColor = System.Drawing.SystemColors.ControlText; lblVertBar.Location = new System.Drawing.Point(x, y); lblVertBar.Name = "lblVertBar" + x.ToString(); lblVertBar.Size = new System.Drawing.Size(barWidth, (cardCellHeight + padding - 1) * BINGOCARDSIZE); lblVertBar.TabIndex = 19; pnlCard.Controls.Add(lblVertBar); lblVertBar.Visible = true; lblVertBar.CreateControl(); lblVertBar.Show(); } // end drawVertBar
// This is the handler for all Bingo Card Buttons // It uses sender argument to determine which Bingo Card button was selected // The argument is of type object and must be converted to type button in // order to change its properties
Bingo Game Welcome to BINGO Enter your name Are you ready to play?Yes No We call one number at a time. Check your card for that number and if found click that cell. We will do the rest, checking for a BINGO or not. The number will appear to the right. If you do not have the number called in your card, click the "Dont Have button to the right. l 16 Dont Bingo Card N G O 1 17 38 5461 11 19 3450 71 10 24S56 68 Free Space 7 20 43 58 73 Bingo Game Welcome to BINGO Enter your name Are you ready to play?Yes No We call one number at a time. Check your card for that number and if found click that cell. We will do the rest, checking for a BINGO or not. The number will appear to the right. If you do not have the number called in your card, click the "Dont Have button to the right. l 16 Dont Bingo Card N G O 1 17 38 5461 11 19 3450 71 10 24S56 68 Free Space 7 20 43 58 73
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started