locked
Visual Studio's propertygrid - How do I reset it?

    Question

  • Hi there,

    As I'm new to the game of C# and visual studio, maybe the question is the wrong place or the answer is so easy it's emberassing, but still...
    (I'm working in Visual studio 2005 beta2 - C# )

    I'm building an VS add in which uses Visual Studio's propertygrid window to display stuff for my class-instances.


    object[] a = new object[1];
    a[0] = aObject;
    ParentToolwindow.SetSelectionContainer (ref a);

     


    That works like a charme... but... I can't seem to figure out how ro 're-set' the property grid.

    I've tried stuff like (no success)
      ParentToolwindow.SetSelectionContainer (null);
      
      a[0] = null;
      ParentToolwindow.SetSelectionContainer (ref a);

    The msdn tells me:
    If SetSelectionContainer is passed an empty Variant, it removes the object displayed.

    But it doesn't show an example (and the link the have there for a general example is no good).

    Who can tell me what the line of code should be. It can't be that difficult... I just can't find it.
    Tuesday, May 17, 2005 11:01 AM

Answers

  • Did you try...


    object [] a = null;
    ParentToolWindow.SetSelectionContainer(ref a);

     

    or


    object[] a = new object[0];
    ParentToolWindow.SetSelectionContainer(ref a);

     


    Just a guess...
    Tuesday, May 17, 2005 3:41 PM

All replies

  • Try:


    object a = null;
    ParentToolWindow.SetSelectionContainer(ref a);

     
    Tuesday, May 17, 2005 11:10 AM
  • Nope, sorry, I tried but it doesn't build...
       " Cannot covert from ref object to ref object [] "
    If I fix this problem so it builds ok.


    object[] a;
    object aEmpty = null;
    a = (object[])aEmpty;

    ParentToolwindow.SetSelectionContainer(ref a);

     

    When running it I get an exeption... 
      "Error HRESULT E_FAIL has been returned from a call to a COM component."


    Tuesday, May 17, 2005 11:58 AM
  • Did you try...


    object [] a = null;
    ParentToolWindow.SetSelectionContainer(ref a);

     

    or


    object[] a = new object[0];
    ParentToolWindow.SetSelectionContainer(ref a);

     


    Just a guess...
    Tuesday, May 17, 2005 3:41 PM
  • Thanks... I thought I tried all combinations I could think up. Guess I didn't think up your second one.  Smile
    It works like a charm!


    Object[] a = new object[0]  
    ParentToolWindow.SetSelectionContainer(ref a);

     



    • Proposed as answer by Fei. _ Friday, September 04, 2009 8:07 AM
    Tuesday, May 24, 2005 7:19 AM