how to get the relative location of the controls within a panel?

Hi,

I am having a panel and the size grows dynamically. I have a horizontal scrollbar and a vertical scrollbar. How do I get the size of the complete panel. When I say panel.size it just gives me the size of the screen that can be viewed. I need to get the complete size of the panel. I also tried to append the panel.AutoScrollMargin.Width. But it is not giving me any value. How can I achieve this task I also want to know how to get the location within the panel where the mouse is clicked. Your help will be appreciated.  

Thank You.

 



Answer this question

how to get the relative location of the controls within a panel?

  • Al_B

    Hi SG,

    Thanks for the reply. But as I mentioned before I used that property and I got a value of 0. My actual thing is I want to add a control dynamically to the panel at the specified location. And I want to find the location of the panel with a scrollbar.

    Thank You


  • AnjaliDevi

    Hi,

    Is your problem solved

    Thank you,
    Bhanu.



  • Dpcsgl

    Hi!

    Panel is subclass of ScrollableControl, so it have AutoScrollMinSize property that must contain size you search.


  • MickB

    You mention AutoScrollMargin.Width and I suggest AutoScrollMinSize - this is very different things :)


  • Program.Net

    Sad that it doesn't work, but you can do it by hands like this:

    Rectangle rect = Rectangle.Empty;

    foreach (Control control in Controls)
    {
    rect = Rectangle.Union(rect, control.Bounds);
    }



  • Davor Vincic

    Hi SG,

    They didnt make big difference. They both gave the same value "0".

    Thanks for the help.


  • how to get the relative location of the controls within a panel?