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

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.



Answer this question

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

  • Gisela

    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);

     





  • bbanks

    Try:


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

     


  • Raj Chidipudi

    Did you try...


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

     

    or


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

     


    Just a guess...

  • Grouchypb

    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."




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