Hi,

Jonathan Pobst wrote:
> 
> So if you aren't explicitly setting the control's column earlier in 
> code, this will return -1.  If you are relying on the TLP to arrange 
> them automatically, you need to use TLP.GetPositionFromControl().
> 

This would explain why

int col = lesson.GetPositionFromControl((Control)sender).Column; returns -1
(though I'm not sure if (Control)sender is correct, it appears to be
though).

The code I've used for inserting the columns is this

public lessonplan(int noperiods)
        {
                        float periodSize = 100.0F / (float)noperiods;
                        InitializeComponent();
                        this.lesson.ColumnCount = noperiods + 1;
                        this.lesson.ColumnStyles.Add(new
System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute,
120F));
                        for (int i = 0; i < noperiods; ++i)
                        {
                                this.periodlabel[i] = new 
System.Windows.Forms.Label();
                                this.lesson.ColumnStyles.Add(new
System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent,
periodSize));
                                this.periodlabel[i].Location = new 
System.Drawing.Point(127 + (117 * i),
2);
                                this.periodlabel[i].Text = "Lesson " + (i +
1).ToString();
                                this.periodlabel[i].AutoSize = true;
                                this.periodlabel[i].Font = new 
System.Drawing.Font("Arial", 18F,
System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point,
((byte)(0)));
                                this.periodlabel[i].Size = new 
System.Drawing.Size(109, 27);
                                this.periodlabel[i].TabIndex = i + 6;
                                this.lesson.Controls.Add(this.periodlabel[i], i 
+ 1, 0);
                        }
                        Invalidate();
        }

This is called when the table is clicked, so it's being set up after the
window is initially set up.

Does this mean that I'm relying on the TLP or something else (which would
also explain the -1)?

TTFN

Paul
-- 
View this message in context: 
http://www.nabble.com/GetColumn-problem-tp25472747p25474634.html
Sent from the Mono - WinForms mailing list archive at Nabble.com.

_______________________________________________
Mono-winforms-list maillist  -  Mono-winforms-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-winforms-list

Reply via email to