locked
Suitable container for dynamic controls RRS feed

  • Question

  • Hello All,

    I am developing a Windows Smartphone application with dynamic user controls on the form. Say, I add 5 user controls programatically to the form, and setting their Top property appropriately, now I remove 3rd user control! I find there is occupied space with empty content, this is because every control have absolute Top set. As a result on the remove action I need to re-iterate through all controls and again set their Top, which is not performance centric solution. To solve this, I tried to keep the user controls in Panel but the Panel is not auto adjusting the vertical alignment of the controls. I thought StackPanel which is available in System.Windows.Controls (PresentationFramework.dll) could be the solution, but surprisingly I seen the library is not available in .Net Compact Framework 3.5 on which my application is targeted. Manually adding dll could result in to problems so not tried out.

    Any suggestions will be greatly appreciated!

    Thanks,

    Mukesh

    Wednesday, November 17, 2010 6:32 AM

Answers

  • Hi,

    Then the only way is rearranging the controls' position in remove button after the removement option I could think of. There is no buildin to achieve this with windows mobile.

    Thanks

    Binze


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Monday, November 22, 2010 5:04 AM

All replies

  • Hi,

    I don't think there is better way you can do for this except you iterate all the user controls in your container and reposition them. This should only achieved at runtime, at design time why not just drag them from you toolbox and position them appropriately.

    I am not sure why you want to do it as you wouldn't like your user to delete a control of your application at runtime, and at design time this shouldn't be a problem since you can always change the control's position in terms of your needs.

    Thanks

    Binze


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Friday, November 19, 2010 6:38 AM
  • Binze,

    Thanks for your inputs.

    Let me make my applcation's functionality better understandable. The idea here is, the Smartphone device application retrieves number of items to render from the server through web-services and hence it's at run time we create user controls and put it on the form. Now, user has privilege to remove the controls he is not happy with through the context sensitive menu. Once he removes the user control the other user controls needs to be auto-positioned.

    Thanks,

    Mukesh

    Monday, November 22, 2010 4:04 AM
  • Hi,

    Then the only way is rearranging the controls' position in remove button after the removement option I could think of. There is no buildin to achieve this with windows mobile.

    Thanks

    Binze


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Monday, November 22, 2010 5:04 AM
  • Thanks Binze.
    Monday, November 22, 2010 8:57 AM