Why is the PropertyDescriptor's GetValue method called multiple times when selecting the descriptor

Discussion in 'ASP .Net Building Controls' started by mark belles, Jan 21, 2004.

  1. mark belles

    mark belles Guest

    i have a scenario in which i am using a ICustomTypeDescriptor in combination with an inherited PropertyDescriptor class to display information about an object using the PropertyGrid provided with .NET. I'm am using C#, and have noticed that the GetValue method which is overridden in my PropertyDescriptor class fires multiple times when the descriptor is placed into the SelectedObject property of the .NET PropertyGrid.

    My 3 Questions are as follows...
    Has anyone else noticed behavior like this?
    Why does this occur?
    How do I prevent it?

    I will be happy to provide example code if anyone needs to see it.
    mark belles, Jan 21, 2004
    #1
    1. Advertising

  2. "mark belles" <> wrote in message
    news:...
    > i have a scenario in which i am using a ICustomTypeDescriptor in

    combination with an inherited PropertyDescriptor class to display
    information about an object using the PropertyGrid provided with .NET. I'm
    am using C#, and have noticed that the GetValue method which is overridden
    in my PropertyDescriptor class fires multiple times when the descriptor is
    placed into the SelectedObject property of the .NET PropertyGrid.
    >
    > My 3 Questions are as follows...
    > Has anyone else noticed behavior like this?
    > Why does this occur?
    > How do I prevent it?


    I have no answer, but I have a question for you: why do you need to prevent
    it? Surely GetValue should be idempotent...
    --
    John Saunders
    John.Saunders at SurfControl.com
    John Saunders, Jan 22, 2004
    #2
    1. Advertising

  3. mark belles

    mark belles Guest

    why do i need to prevent it? it just seems terribly inefficient to watch the grid call into the descriptor so many times. i would think that once before drawing, and then perhaps again after changes to a property, assuming you raised the event using the change service. even displaying a single property in the grid, the getvalue method is called really frequently. usually twice everytime the thing paints, or before a UITypeEditor is shown. lol, so all in all it works yes, just bothers me and i want to know why?

    it's like if i had a control that fired the paint event several times in succession for no apparent reason. Would that bother you, or at least strike an inquisitive bone so that you might have to ask? lol, anyways, it's apparently nothing i can control, so i'm not really worried, i'd still like to know tho.
    mark belles, Jan 23, 2004
    #3
  4. "mark belles" <> wrote in message
    news:...
    > why do i need to prevent it? it just seems terribly inefficient to watch

    the grid call into the descriptor so many times. i would think that once
    before drawing, and then perhaps again after changes to a property, assuming
    you raised the event using the change service. even displaying a single
    property in the grid, the getvalue method is called really frequently.
    usually twice everytime the thing paints, or before a UITypeEditor is shown.
    lol, so all in all it works yes, just bothers me and i want to know why?
    >
    > it's like if i had a control that fired the paint event several times in

    succession for no apparent reason. Would that bother you, or at least strike
    an inquisitive bone so that you might have to ask? lol, anyways, it's
    apparently nothing i can control, so i'm not really worried, i'd still like
    to know tho.


    Actually, if I saw GetValue called multiple times, say, up to 10, or perhaps
    up to 4*the number of objects in the property grid, then I'd assume there
    was some reason for it that I simply didn't understand.

    If I saw it called, say, 100*the number of objects, I'd wonder if it was a
    bug.
    --
    John Saunders
    John.Saunders at SurfControl.com
    John Saunders, Jan 23, 2004
    #4
  5. mark belles

    mark belles Guest

    i agree totally on the number of times called theory. i've already tried to figure out if it was related to the number of things i was showing, and it's not, it appears constant, give or take a call here and there. as far as i can tell, it's calling GetValue 7 times the first time the grid is loaded, this is up to the point i see the control, tracing with spy++ the first time until after the first paint message. it doesn't matter if i have 1 propertydescriptor or 50 in the grid, it's 7 calls for each. and then depending on the type of the property and uitypeeditor attached, anywhere from 2 to 6 calls again until after the editor is closed.

    obviously this is by design, and obviously i don't get why, which is why i'm asking on here. lol odd eh?
    mark belles, Jan 23, 2004
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. djskrill
    Replies:
    9
    Views:
    696
    djskrill
    Oct 1, 2003
  2. Apricot
    Replies:
    4
    Views:
    523
    velthuijsen
    Apr 16, 2004
  3. Mr. SweatyFinger
    Replies:
    2
    Views:
    1,805
    Smokey Grindel
    Dec 2, 2006
  4. Christopher Carnahan

    DataGrid WebControl does not use PropertyDescriptor.GetValue

    Christopher Carnahan, Sep 3, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    110
    Christopher Carnahan
    Sep 3, 2004
  5. Christopher Carnahan

    DataGrid WebControl does not use PropertyDescriptor.GetValue

    Christopher Carnahan, Sep 3, 2004, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    138
    Christopher Carnahan
    Sep 3, 2004
Loading...

Share This Page