none
Need to know about the kind(button, textbox, list or combo) of .NET control after custom based serialization?

    Question

  • Hello,

    In the process of serializing .NET control object to custom object( sayMyControlObject) to the other process for some purpose , I need to re-draw these controls in custom manner. For that I need to know what type it is like ( its is button, textbox, combo box, TextField, Calander, ToolStrip,TtoolstripMenu,RichTextBox,TabControl or TreeView it is). For that I might need sort of typeOf(RichTextBox) == RichTextBox sort of check.

    I will be very obliged and thankfull , if any body having idea about this?

    Regards Usman

    Wednesday, May 18, 2011 3:47 PM

Answers

  • VB

    If TypeOf sender Is ListBox Then
    

    C#

     if (sender is ListBox) { }
    


    Success
    Cor
    • Marked as answer by Neddy Ren Wednesday, May 25, 2011 8:07 AM
    Thursday, May 19, 2011 8:01 AM
  • Hi Usman Khalil,

    With the two processes, do both of processes reference to the same custom object? Or does the custom object just refer to only one process?

    If both of the applications run and add the same custom control as references, you can use Cor Ligthert's suggestion and it's cool way and conventient to resolve this issue.

    If not, you will need to use Reflection to create the Type at runtime, or you can't got the Type information.

    On how to use reflection to create the Type, please see the following page:

    How to: Define a Generic Type with Reflection Emit:
    http://msdn.microsoft.com/en-us/library/4xxf1410.aspx

    Best Regards
     


    Neddy Ren [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.

    • Marked as answer by Neddy Ren Wednesday, May 25, 2011 8:07 AM
    Friday, May 20, 2011 8:50 AM

All replies

  • VB

    If TypeOf sender Is ListBox Then
    

    C#

     if (sender is ListBox) { }
    


    Success
    Cor
    • Marked as answer by Neddy Ren Wednesday, May 25, 2011 8:07 AM
    Thursday, May 19, 2011 8:01 AM
  • Hi Usman Khalil,

    With the two processes, do both of processes reference to the same custom object? Or does the custom object just refer to only one process?

    If both of the applications run and add the same custom control as references, you can use Cor Ligthert's suggestion and it's cool way and conventient to resolve this issue.

    If not, you will need to use Reflection to create the Type at runtime, or you can't got the Type information.

    On how to use reflection to create the Type, please see the following page:

    How to: Define a Generic Type with Reflection Emit:
    http://msdn.microsoft.com/en-us/library/4xxf1410.aspx

    Best Regards
     


    Neddy Ren [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.

    • Marked as answer by Neddy Ren Wednesday, May 25, 2011 8:07 AM
    Friday, May 20, 2011 8:50 AM