Hi, I don't know where the problem lies with this one as I'm seeing the same behaviour with mono and under VS 2010 on Linux and Windows platforms.
I have a simple winform which has in it a NumericUpDown, two group boxes and two buttons. The code then dynamically inserts a number of NumberBox objects into one group box and a pile of labels into the other. (A numberbox is just an overloaded TextBox - details are at http://www.all-the-johnsons.co.uk/csharp/numberbox.html) If I click the NumericUpDown, the code inserts new boxes and also reduces it as expected. However, if I click once to create 3 boxes and then go back down to 2, half of the third row still remains and I have no idea why! NumericUpDown goes from 3 to 6, no decimals [code] private void numericUpDown1_ValueChanged(object sender, EventArgs e) { drawBoxes((int)numericUpDown1.Value); } private void drawBoxes(int number) { int ar = number; int b = ar; int p = 0; // position int r = 0; // current row ar = Convert.ToInt32(Math.Pow(ar, 2)); NumberBox[] tmp = new NumberBox[ar]; Label[] lbl = new Label[ar]; int t = 0; int m = 65; for (int n = 0; n < ar; ++n) { m += n; tmp[n] = new NumberBox(); tmp[n].Location = new System.Drawing.Point(7 + p, 20 + (26 * r)); tmp[n].Name = "numberBox" + n.ToString(); tmp[n].Size = new System.Drawing.Size(42, 20); tmp[n].TabIndex = n; groupBox1.Controls.Add(tmp[n]); lbl[n] = new Label(); lbl[n].Location = new System.Drawing.Point(7 + p, 20 + (26 * r)); lbl[n].Name = "label" + m.ToString(); lbl[n].Text = "0"; lbl[n].Size = new System.Drawing.Size(42, 20); lbl[n].TabIndex = m; groupBox2.Controls.Add(lbl[n]); p += 48; if (t + 1 != b) t++; else { t = 0; r++; p = 0; } } int z = 8 + b * 48; int y = 8 + (b * 26) + 16; groupBox1.Size = new System.Drawing.Size(z, y); groupBox2.Location = new System.Drawing.Point(32 + b * 48, 43); groupBox2.Size = new System.Drawing.Size(z, y); this.clear.Location = new System.Drawing.Point(16, y + 48); this.calc.Location = new System.Drawing.Point(97, y + 48); ClientSize = new System.Drawing.Size(z * 2 + 32, y + 80); nbArray = tmp; // global variable rdArray = lbl; // global variable } I've gone through the code with the debugger, but can't spot anything out of the ordindary. I've also tried adding an Invalidate() at the end of the method, but still it gives the half box. Any help here would be appreciated Thanks Paul -- Vertraue mir, ich weiss, was ich mache... _______________________________________________ Mono-winforms-list maillist - Mono-winforms-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-winforms-list