We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Controls in FlowLayout all have same Control.Location?

Hello,

I have a Panel (docked in a Form) that is the ControlContainer for a FlowLayout Manager. I programmatically add a number of buttons to it and then do custom drawing on the main Form based on the location of the buttons.

The problem is that all of the buttons seem to have the same location. Visually they are laid out correctly, but in code their Location property returns the same Point.

This does not happen if I use the Windows.Forms.FlowLayoutPanel in lieu of the regular Panel and FlowLayout Manager.

Is this a known problem, or am I going about this the wrong way?

Keith

5 Replies

SA Saradha Syncfusion Team September 26, 2006 01:15 PM UTC

Hi Keith,

We are unable to figure out the issue that you are facing. It would be highly helpful if you can attach your sample or modify the attached sample. Once we can reproduce this we will be able to fix this issue at the earliest.

Forum_49723


Thanks for using Syncfusion products.

Regards,
K.Saradha Devi.



AD Administrator Syncfusion Team September 26, 2006 08:39 PM UTC

Here is a project showing this behavior. I''ve tried forcing updating of the layout, tried adding the controls directly to the LayoutControls collection, etc. but haven''t been successful.

If controls are added in the designer, they have proper locations.



FlowLayoutTest.zip


SA Saradha Syncfusion Team September 27, 2006 04:58 AM UTC

Hi Keith,

It is the nature of FlowLayout manager to add all its controls in the beginning of the container. When button2 is added, the flow layout manager moves button1 down and places button2 in the beginning which is again moved down when another button is added. Please refer the screenshot which illustrates this.
FlowLayout.zip


You are setting the text of buttons under this situation. To get the loction of controls, you will have to check it after all controls are added to the form.

Refer the modified sample and let me know if you have any questions. Thanks for using syncfusion products.
FlowLayoutTest.zip


Regards,
K.Saradha Devi.



AD Administrator Syncfusion Team September 27, 2006 05:11 PM UTC

Thanks for the reply.

So does this mean I have to wait for the window to be shown before I can get the correct Locations of the controls in the FlowLayout? Or is there an event I can attach to that will let me know when it is ok to get Location information? I looked through the Form, Panel and FlowLayout events and didn''t see anything.

Keith


MJ Mano J Syncfusion Team September 27, 2006 09:22 PM UTC

Hi Keith,

Please use the Panel''s paint event to return the location correctly.

private void panel1_Paint (object sender, PaintEventArgs e)
{
foreach (Button button in this.panel1.Controls)
{
button.Text = button.Location.ToString();
}
}

Regards,
Mano

Loader.
Live Chat Icon For mobile
Up arrow icon