I think the GetVisibleRectangle method that I wrote below is what you requested. Successive runs of this with scrolling gave the following result: scrolling the control:
- {X = 0, Y = 0, Width = 0, Height = 0} - button 4 was scrolled out of sight. Please note that here is the meaning
Rectangle.Empty. - {X = 211, Y = 36, = 25, = 13} - 4, .
- {X = 161, Y = 36, = 75, = 13} - 4, .
- {X = 161, Y = 26, = 75, = 23} - 4,
, X Y .
:
private void button1_Click(object sender, EventArgs e)
{
Rectangle r = GetVisibleRectangle(this.panel1, button4);
System.Diagnostics.Trace.WriteLine(r.ToString());
}
public static Rectangle GetVisibleRectangle(ScrollableControl sc, Control child)
{
Rectangle work = child.Bounds;
work.Intersect(sc.ClientRectangle);
return work;
}