Hi Yasutaka,
There is no method in the frame work to do that.
However you can use the way the control layouts its children and found it
yourself.
Controls starts layouting the contols from the last in the Controls
collection moving backwords to the index 0. So if you can get the index of
the control in question and move form this index to the end of collection.
The control you are looking for is the first sibling with the same value for
the Dock property.
If no control is found that means the control is docked against the edge of
its parent.
The check doesn't make sense if the Dock is set to Fill or None because in
the first case it is docked against the all surrounding siblings; the second
case is obvious.
this is an example of how to do it:
public Control DockAgainst(Control ctrl)
{
if(ctrl.Dock == DockStyle.None || ctrl.Dock == DockStyle.Fill)
{
return null;
}
Control parent = ctrl.Parent;
int index = parent.Controls.GetChildIndex(ctrl);
for(int i = index + 1; i < parent.Controls.Count; i++)
{
Control nextCtrl = parent.Controls[i];
if(ctrl.Dock == nextCtrl.Dock)
{
return nextCtrl;
}
}
return null;
}
--
HTH
B\rgds
100
"Yasutaka Ito" <no****@nonexistent.com> wrote in message
news:ei*************@tk2msftngp13.phx.gbl...
Oops, seems like I wasn't explaining it properly.
By saying 'dock', I meant, setting the control's Dock property.
So, according to the example I gave in my previous post, I'm setting the
Dock property of panel1 and panel2. The panel1 is docked against the left
of its container (the form), and the panel2 is docked against the panel1.
The results I'm expecting from the above example is.... when I'm given
panel2, I should be able to find out as a result that it is docked against
panel1
thanks!
-Yasutaka
"Cor" <no*@non.com> wrote in message
news:Oo**************@TK2MSFTNGP11.phx.gbl... Hi Yasutaka Ito
You mean this one?
Myparent = MyControl.Parent.Name.ToString
I hope this was what you where looking for?
Cor