[Mono-winforms-list] GetColumn problem

Jonathan Pobst monkey at jpobst.com
Wed Sep 16 10:10:32 EDT 2009

According to the docs for TLP.GetColumn ():

The column position of the specified child control, or -1 if the 
position of control is determined by LayoutEngine.

To get the actual position of control, even when its position is 
determined by LayoutEngine, call the GetPositionFromControl method.

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().


PFJ wrote:
> Hi,
> I have a tablelayoutpanel called lesson. This contains a number of rows and
> columns. I have a generic mouseclick event attached to it.
> In the event I want to find the x and y position of the mouse as well as the
> column.
> No problems with the x and y position (MousePosition.x and MousePosition.y
> do the job splendidly), however, I can't seem to get the column number.
> Currently, my code looks like this
> int colno = lesson.GetColumn((Control)sender)); 
> (it has had a pile of different things in the place of Control above).
> When I output colno to a label (for debugging), it always gives  -1
> irrespective of the column clicked. I'm probably really close, but just
> can't quite get it right.
> A little help?
> Paul

More information about the Mono-winforms-list mailing list