1
I believe it’s a bug not the code, but the compiler...
When I eat this area of code, the error always goes to the next variable, or method.
Part of the code:
grpBoxMDeck[i] = new System.Windows.Forms.GroupBox()
{
Location = new System.Drawing.Point(76, yG),
Size = new System.Drawing.Size(536, 340),
BackColor = System.Drawing.Color.Transparent,
ForeColor = corLetra,
Font = new System.Drawing.Font(Font.FontFamily, 8.25f, System.Drawing.FontStyle.Bold),
Text = string.Format("Elixir Médio: {0:f1} - Arena {1}+", elixirMedio, decks[i].Split('|')[1]).Replace(',', '.')
};
grpBoxMDeck[i].Click += (s, e) => pMelhoresDecks.Select();
grpBoxMDeck[i].ContextMenuStrip = cmsGBMDecks[i];
picImagemMDecks[i] = new System.Windows.Forms.PictureBox[8];
byte x1 = 3, x2 = 3;
for (byte j = 0; j < picImagemMDecks.Length; j++)
{
byte copiaJ = j;
picImagemMDecks[i][j] = new System.Windows.Forms.PictureBox()
{
Size = new System.Drawing.Size(131, 157),
SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage,
BackColor = System.Drawing.Color.Transparent
};
if (j < 4) { picImagemMDecks[i][j].Location = new System.Drawing.Point(x1, 15); x1 += 133; }
else { picImagemMDecks[i][j].Location = new System.Drawing.Point(x2, 174); x2 += 133; }
grpBoxMDeck[i].Controls.Add(picImagemMDecks[i][j]);
}
pMelhoresDecks.Controls.Add(grpBoxMDeck[i]);
Any solution to this bug? It appeared out of nowhere, the code ran normally, even that last line:
pMelhoresDecks.Controls.Add(grpBoxMDeck[i]);
Now not even it runs. I tried to close and open Visual Studio and nothing!
Wow, the compiler’s been around for years, millions of people use it every day, and no one had ever taken this bug in it? How did you manage to catch this mistake? You studied a lot of programming to get it?
– Maniero
Where is the statement of
pMelhoresDecks
?– Maniero
One of your controls isn’t initialized, they’re null. To know which one, press F9 (to put a breakpoint) on the control line and check each of them (stopping over them with the mouse, or clicking on them and pressing Shift+F9). This is not a bug in the compiler, it is in the same code.
– Leticia Rosa
Leticia, all controls are initialized, until the first exception appears in the declaration of the variable byte X1 = 3; .
– Lucas Bittencourt
I could solve it like this: picImagemMDecks = new System.Windows.Forms.Picturebox[deck. Length > 10 ? 10 : decks.Length][];
– Lucas Bittencourt