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.
Unfortunately, activation email could not send to your email. Please try again.

Controls in FlowLayout all have same Control.Location?

Thread ID:

Created:

Updated:

Platform:

Replies:

49723 Sep 25,2006 02:32 PM Sep 27,2006 05:22 PM Windows Forms 5
loading
Tags: Tools
Administrator [Syncfusion]
Asked On September 25, 2006 02:32 PM

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

Saradha [Syncfusion]
Replied On September 26, 2006 09:15 AM

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.


Administrator [Syncfusion]
Replied On September 26, 2006 04:39 PM

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

Saradha [Syncfusion]
Replied On September 27, 2006 12:58 AM

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.


Administrator [Syncfusion]
Replied On September 27, 2006 01:11 PM

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

Mano J [Syncfusion]
Replied On September 27, 2006 05:22 PM

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

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;