Re: [Mono-winforms-list] GetColumn problem

2009-09-17 Thread Jonathan Pobst
PFJ wrote:
> I have created a TLP in the designer which contains 6 rows and 1 column. The
> column contains the days of the week and a blank at the top.
> 
> The user enters the number of columns they want (1 to 10) and the program
> creates them using the code I've posted. On Row0, the labels saying the
> lesson number are added in. There are no other labels in anywhere else.
> 
> What I'm trying to do is when the TLP is clicked, that the program finds the
> row and column for use elsewhere in the application.
> 
> My current efforts *always* return -1 when using GetColumn or
> GetPositionFromControl. I'm assuming it's giving -1 as there is nothing
> inside of the layout blocks other than the labels in row 0 and column 0.

Yeah, GetColumn/GetPositionFromControl are designed to find where a 
Control is in the TableLayoutPanel.  I don't think there's much that 
helps you use TLP as just a grid.

You will probably need to use GetColumnWidths and GetRowHeights to 
calculate which col/row was clicked using the mouse coordinates from 
MouseClick.

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


Re: [Mono-winforms-list] GetColumn problem

2009-09-17 Thread PFJ

Hi,


Jonathan Pobst wrote:
> 
> Paul wrote:
>> Sorry for this being a dumb question, but can you explain this? I'm
>> doing things I've never done before, so you need to be gentle with
>> me ;-)
> 
> Maybe we need to step back a little bit, what are you trying to do?
> 

I have created a TLP in the designer which contains 6 rows and 1 column. The
column contains the days of the week and a blank at the top.

The user enters the number of columns they want (1 to 10) and the program
creates them using the code I've posted. On Row0, the labels saying the
lesson number are added in. There are no other labels in anywhere else.

What I'm trying to do is when the TLP is clicked, that the program finds the
row and column for use elsewhere in the application.

My current efforts *always* return -1 when using GetColumn or
GetPositionFromControl. I'm assuming it's giving -1 as there is nothing
inside of the layout blocks other than the labels in row 0 and column 0.

I've filed a bug as there is a winforms problem currently (the border style
is not working correctly) and have attached the full source to that bug (BZ
539606) - this may help...

TTFN

Paul

-- 
View this message in context: 
http://www.nabble.com/GetColumn-problem-tp25472747p25487704.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


Re: [Mono-winforms-list] GetColumn problem

2009-09-16 Thread Jonathan Pobst
Paul wrote:
> Sorry for this being a dumb question, but can you explain this? I'm
> doing things I've never done before, so you need to be gentle with
> me ;-)

Maybe we need to step back a little bit, what are you trying to do?

We think you have a grid (TableLayoutPanel) with some controls in it 
(Labels?), and you want to know the column of the grid that a specific 
Label is in.

so if:
- lesson is your TableLayoutPanel
- mylabel is the Label you want to find the column of

you would do:
int col = lesson.GetPositionFromControl (mylabel).Column;

If this isn't what you are going for, then please explain that and we'll 
help you out.  ;)

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


Re: [Mono-winforms-list] GetColumn problem

2009-09-16 Thread Paul
Hi,

> > int col = lesson.GetPositionFromControl((TableLayoutPanel)sender).Column;
> > int row = lesson.GetPositionFromControl((TableLayoutPanel)sender).Row;
> >
> > is also giving -1 for both (as does
> > GetRow/GetColumn((TLP)sender).Row/Column)
> >
> > ??? What is going on?
> 
> You are asking the tablelayoutpanel for the column and row (the cell)
> fo the tablelayoutpanel :). You need to supply an argument that is a
> child control of the tablelayoutpanel.

Sorry for this being a dumb question, but can you explain this? I'm
doing things I've never done before, so you need to be gentle with
me ;-)

TTFN

Paul

-- 
Sie können mich aufreizen und wirklich heiß machen!


signature.asc
Description: This is a digitally signed message part
___
Mono-winforms-list maillist  -  Mono-winforms-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-winforms-list


Re: [Mono-winforms-list] GetColumn problem

2009-09-16 Thread Ivan Zlatev
On Wed, Sep 16, 2009 at 5:08 PM, PFJ  wrote:
>
> int col = lesson.GetPositionFromControl((TableLayoutPanel)sender).Column;
> int row = lesson.GetPositionFromControl((TableLayoutPanel)sender).Row;
>
> is also giving -1 for both (as does
> GetRow/GetColumn((TLP)sender).Row/Column)
>
> ??? What is going on?

You are asking the tablelayoutpanel for the column and row (the cell)
fo the tablelayoutpanel :). You need to supply an argument that is a
child control of the tablelayoutpanel.

Kind Regards,
Ivan Zlatev
http://ivanz.com
___
Mono-winforms-list maillist  -  Mono-winforms-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-winforms-list


Re: [Mono-winforms-list] GetColumn problem

2009-09-16 Thread PFJ

Hi,


Jonathan Pobst wrote:
> 
> PFJ wrote:
>> In that case, why is GetPositionFromControl returning -1 for column and
>> not
>> the actual column number? Is this a bug?
> 
> I guess it is either a bug in Mono or your code.  ;)
> 
> If the MouseClick event you are attached to is on the TLP, the sender 
> will most likey be the TLP and not the control if you are doing this:
> 
> int colno = lesson.GetColumn((Control)sender));
> 

int col = lesson.GetPositionFromControl((TableLayoutPanel)sender).Column;
int row = lesson.GetPositionFromControl((TableLayoutPanel)sender).Row;

is also giving -1 for both (as does
GetRow/GetColumn((TLP)sender).Row/Column) 

??? What is going on?

TTFN

Paul




-- 
View this message in context: 
http://www.nabble.com/GetColumn-problem-tp25472747p25475629.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


Re: [Mono-winforms-list] GetColumn problem

2009-09-16 Thread Jonathan Pobst
PFJ wrote:
> In that case, why is GetPositionFromControl returning -1 for column and not
> the actual column number? Is this a bug?

I guess it is either a bug in Mono or your code.  ;)

If the MouseClick event you are attached to is on the TLP, the sender 
will most likey be the TLP and not the control if you are doing this:

int colno = lesson.GetColumn((Control)sender));

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


Re: [Mono-winforms-list] GetColumn problem

2009-09-16 Thread PFJ

Hi,


Jonathan Pobst wrote:
> 
>> Does this mean that I'm relying on the TLP or something else (which would
>> also explain the -1)?
> 
> It appears you are relying on the TLP.  If you were setting the column 
> explicitly, it would look roughly like this:
> 

In that case, why is GetPositionFromControl returning -1 for column and not
the actual column number? Is this a bug?

TTFN

Paul
-- 
View this message in context: 
http://www.nabble.com/GetColumn-problem-tp25472747p25475203.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


Re: [Mono-winforms-list] GetColumn problem

2009-09-16 Thread Jonathan Pobst
> Does this mean that I'm relying on the TLP or something else (which would
> also explain the -1)?

It appears you are relying on the TLP.  If you were setting the column 
explicitly, it would look roughly like this:

TableLayoutPanel tlp = new TableLayoutPanel ();
Label l1 = new Label ();
Label l2 = new Label ();

tlp.SetColumn (l1, 1);
tlp.SetRow (l1, 1);

tlp.SetColumn (l2, 2);
tlp.SetRow (l2, 1);

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


Re: [Mono-winforms-list] GetColumn problem

2009-09-16 Thread PFJ

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


Re: [Mono-winforms-list] GetColumn problem

2009-09-16 Thread Jonathan Pobst
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().

Jonathan


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?
> 
> TTFN
> 
> Paul

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


[Mono-winforms-list] GetColumn problem

2009-09-16 Thread PFJ

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?

TTFN

Paul
-- 
View this message in context: 
http://www.nabble.com/GetColumn-problem-tp25472747p25472747.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