Prev: newbie help with elearning sample console.writeline
Next: Reminder - Microsoft Responds to the Evolution of Community
From: Mr. X. on 20 Jun 2010 15:23 When PropertyGrid is connected to a selectedObject : How can I run through all of the object properties, which are seen on the propertyGrid, and get the name + value ? (What is behind PropertyGrid ?) Thanks :)
From: Mr. Arnold on 20 Jun 2010 15:58 Mr. X. wrote: > When PropertyGrid is connected to a selectedObject : > How can I run through all of the object properties, which are seen on > the propertyGrid, and get the name + value ? > (What is behind PropertyGrid ?) > > Thanks :) You would use .NET Reflection to do it. <http://www.switchonthecode.com/tutorials/csharp-tutorial-using-reflection-to-get-object-information>
From: Armin Zingler on 20 Jun 2010 15:57 Am 20.06.2010 21:23, schrieb Mr. X.: > When PropertyGrid is connected to a selectedObject : > How can I run through all of the object properties, which are seen on the > propertyGrid, and get the name + value ? > (What is behind PropertyGrid ?) What is the problem with the solution you already have? Doesn't it work? -- Armin
From: Mr. X. on 20 Jun 2010 16:20 No. (I have answered the previous thread). As your advise, I did getProperties & getCustomAttributes either : prs = ... getProperties for I = 0 to prs.count - 1 dim prop = prs(j) dim atts = prop.GetCustomAttributes for each att in atts ... ' as your code below. .... but I have reach the inner loop only when :specialAtt.Visibility was hidden. (And I don't get all of the properties, that are seen on the designer : properties view). It doesn't meter whether I use a serializable object or using Reflection, but, I see that serializable isn't possible for Panel, I.e, and I didn't understand reflection (I don't know if I should use getProperties method, or getFields method - both don't return the same fields' count as the property grid does on design time). Thanks :) "Armin Zingler" <az.nospam(a)freenet.de> wrote in message news:Ok6v3LLELHA.5736(a)TK2MSFTNGP02.phx.gbl... > Am 20.06.2010 21:23, schrieb Mr. X.: >> When PropertyGrid is connected to a selectedObject : >> How can I run through all of the object properties, which are seen on the >> propertyGrid, and get the name + value ? >> (What is behind PropertyGrid ?) > > What is the problem with the solution you already have? Doesn't > it work? > > > -- > Armin
From: Mr. X. on 20 Jun 2010 16:29
Let's a look of PictureBox, for example. PictureBox has 28 properties, that are seen on design-time. When I do dim myPictureBox as PictureBox myPictureBox.GetType().GetProperties().count ' count = 81 myPictureBox.GetType().GetFields().count ' count = 0 So I filter (by loop) : prs = myPictureBox.GetType().GetProperties() j = 0 for I = 0 to prs.count - 1 if prs(I).canRead andAlso prs(I).canWrite andAlso prs(I).PropertyType.TypeInitializer Is Nothing then j = j + 1 end if next .... now k = 25 (almost, but the properties don't match the original properties. Here is the new list : BorderStyle ErrorImage Font Image InitialImage ImeMode RightToLeft SizeMode TabIndex AccessibleRole Anchor BackgroundImage BackgroundImageLayout BindingContext ContextMenu ContextMenuStrip Dock Height Left Region Site Tag Top Width WindowTarget ----------- There must be somewhere an example arround the internet, but I cannot find one. Need simple sample - how to retrieve & store, I.e., a Panel with all of its properties, please. Thanks :) "Mr. Arnold" <Arnold(a)Arnold.com> wrote in message news:eCurJMLELHA.4816(a)TK2MSFTNGP04.phx.gbl... > Mr. X. wrote: >> When PropertyGrid is connected to a selectedObject : >> How can I run through all of the object properties, which are seen on the >> propertyGrid, and get the name + value ? >> (What is behind PropertyGrid ?) >> >> Thanks :) > > You would use .NET Reflection to do it. > > <http://www.switchonthecode.com/tutorials/csharp-tutorial-using-reflection-to-get-object-information> > |