none
Control.FindForm not work when control is docked out of form. RRS feed

  • Domanda

  • Hello All,

    I am working on one application which allow user dock panel out side of form for better view and fast work.

    I have custom control which access some property of Form.

    I use control.FindForm() and then Form GetProperty() with proprty name

    but it sounds like when my panel is not dock inside form Control.FindForm return null and my code is not work properly.

     

    I am looking on this but didn't find any answer please let me know other option available.

    I dont want to take control.parent because it's not directly in form it's in panel and with docking groupbox and dock manager is handle this for Form.

     

    Thanks and Regards

     

    giovedì 6 ottobre 2011 12:29

Risposte

  • The FindForm() method will find the Form of your control, no matter if there's any panel like container in the middle of them.

    How you that Custom Control like, and how do you add this Custom Control on to the Form?

    It is not very clear that you said there's a panel can dock out side of Form.

    It is better that if you can provide a sample project. Use the sky driver, and then share the download link in your post.

     

    If there's any concern, please feel free to let me know.

    Best wishes,


    Mike [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Contrassegnato come risposta Asif A Huddani martedì 16 luglio 2013 14:54
    venerdì 7 ottobre 2011 06:35
    Moderatore

Tutte le risposte

  • Which code you use to dock control out of form ? SetParent or ?

    You should add property "Form" to your "panel" and check type of "Control.TopLevelControl". If top level control is panel than get form from panel property.


    giovedì 6 ottobre 2011 13:09
  • The FindForm() method will find the Form of your control, no matter if there's any panel like container in the middle of them.

    How you that Custom Control like, and how do you add this Custom Control on to the Form?

    It is not very clear that you said there's a panel can dock out side of Form.

    It is better that if you can provide a sample project. Use the sky driver, and then share the download link in your post.

     

    If there's any concern, please feel free to let me know.

    Best wishes,


    Mike [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Contrassegnato come risposta Asif A Huddani martedì 16 luglio 2013 14:54
    venerdì 7 ottobre 2011 06:35
    Moderatore
  • The FindForm() method will find the Form of your control, no matter if there's any panel like container in the middle of them.

    How you that Custom Control like, and how do you add this Custom Control on to the Form?

    It is not very clear that you said there's a panel can dock out side of Form.

    It is better that if you can provide a sample project. Use the sky driver, and then share the download link in your post.

     

    If there's any concern, please feel free to let me know.

    Best wishes,


    Mike [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Hi Mike,

    I think control is added to some container and that container is moved out side of Form using SetParent method.
    venerdì 7 ottobre 2011 12:16
  • But I made a demo according to your description, the FindForm also give me the expected value, the original Form.

    And if we want get the current Form, then I think we can use the current parent control(SetParent function second parameter) to call the FindForm method, then the return value is the current Form.


    Mike [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    sabato 8 ottobre 2011 08:15
    Moderatore
  • I am writing to check the status of the issue on your side. 
    What about this problem now? 
    Would you mind letting us know the result of the suggestions?

    Mike [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    martedì 11 ottobre 2011 09:22
    Moderatore