Setting RowSpan property at run-time for a TableLayoutPanel

H

Helmut Giese

Hello out there,
When I place a control at design-time into a TableLayoutPanel the
control gets a new property 'RowSpan' (which I can set as needed to
have it span multiple fields).

Problem: I am populating the panel at run-time and don't arrive at a
way to set this 'RowSpan' property.
When I say
myCtrl.RowSpan = 2;
I get the compiler error
System...Control does not contain a definition for 'RowSpan'
- which is correct, as a 'stand-alone' control doesn't have it.

But at run-time, once the control is placed into the panel, this
property will exist (I think - I see it in the property editor as soon
as I put the control into the panel).

Q: How to set the RowSpan property at run-time? Could reflection be of
any help here?

Any advice will be greatly appreciated.
Best regards
Helmut Giese
 
P

Peter Duniho

[...]
But at run-time, once the control is placed into the panel, this
property will exist (I think - I see it in the property editor as soon
as I put the control into the panel).

The property isn't really a property added to the control class per se.
It's a bit of sleight-of-hand done by cooperation between the
TableLayoutPanel and the VS Designer.
Q: How to set the RowSpan property at run-time? Could reflection be of
any help here?

No. Please see the documentation for the TableLayoutPanel control class:
http://msdn.microsoft.com/en-us/library/system.windows.forms.tablelayoutpanel.aspx

In particular, see the first "Note:" under the "Remarks" section.

Pete
 
H

Helmut Giese

Hi Pete,
thanks a million - you saved my day.
(To create the layout at run-time is a central part of the design idea
and when it suddenly looked like a major part of it wouldn't be
possible - well, it wasn't exactly a nice feeling.)
[...]
But at run-time, once the control is placed into the panel, this
property will exist (I think - I see it in the property editor as soon
as I put the control into the panel).

The property isn't really a property added to the control class per se.
It's a bit of sleight-of-hand done by cooperation between the
TableLayoutPanel and the VS Designer.
Hey, cute, seems like the property grid is quite interesting. Do you
happen to have a link to some exhaustive docs about it?

Again many thanks
Helmut Giese
 
P

Peter Duniho

[...]
The property isn't really a property added to the control class per se.
It's a bit of sleight-of-hand done by cooperation between the
TableLayoutPanel and the VS Designer.

Hey, cute, seems like the property grid is quite interesting. Do you
happen to have a link to some exhaustive docs about it?

Sorry, no. I don't use the property grid myself, so I'm not that familiar
with where its various behaviors are documented.

I could spend some time with MSDN's or Google's search features and try to
dig something up, but then...you can do that too. :)

Pete
 
H

Helmut Giese

Hi Pete,
[...]
The property isn't really a property added to the control class per se.
It's a bit of sleight-of-hand done by cooperation between the
TableLayoutPanel and the VS Designer.

Hey, cute, seems like the property grid is quite interesting. Do you
happen to have a link to some exhaustive docs about it?

Sorry, no. I don't use the property grid myself, so I'm not that familiar
with where its various behaviors are documented.

I could spend some time with MSDN's or Google's search features and try to
dig something up, but then...you can do that too. :)
sure, asking just in case ...
Currently I am still quite happy with your help to my original
question.
Best regards
Helmut Giese
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top