[RESOLVED] PropertyGrid appearence
I want to display my properties like below
Group1 -----> ??????
Raster Image settings ----> Category
CLUT ----> Property name
I know that each property has only two attributes
1) DescriptionAttribute and
2) CategoryAttribute
But i have to display like above, is there any possibility/alternate way to display like above
Re: PropertyGrid appearence
Hi Eri523, can u give me any suggesion?
cant we put the properties in sub-catagories like i said above ??
Re: PropertyGrid appearence
Without having ever used a property grid in one of my apps or any deeper reseach, here's a shot in the dark: Couldn't you simply represent your groups as property tabs?
Quote:
Originally Posted by
kumsudheer
Hi Eri523, can u give me any suggesion?
Thianks for your trust in my abilities :), but what again about that bumping? ;) You don't even gain anything substantial by doing that: In a forum section with traffic as low as the one here, your post will still be on top of the list after such a short time anyway.
Re: PropertyGrid appearence
Quote:
Originally Posted by
Eri523
No Eri, I need only such requirement, but anyhow I ll try to do it some other way
Quote:
Originally Posted by
Eri523
but what again about that bumping? ;) You don't even gain anything substantial by doing that: In a forunm section with traffic as low as the one here, your post will still be on top of the list after such a short time anyway.
Actually i dont want do it but i was in hurry to see any replies, next time i ll avoid it.
Thank for the reply :)
Re: PropertyGrid appearence
Quote:
Originally Posted by
kumsudheer
No Eri, I need only such requirement, but anyhow I ll try to do it some other way
An alternative idea I had before I got to the property tabs and then abandoned was to use multiple property grids (one for each group), and put each on its own dialog tab. However, that may look somewhat awkward and not be an option for you either. In Addition, it would require you to create wrapper classes for each subset of properties of the actual object that you want to expose as a tab.
Re: PropertyGrid appearence
When the WF property grid is rehosted, it is very plain. There are not even any gridlines separating the properties and their values. How can I customize the property grid appearance?.
Re: PropertyGrid appearence
AFAICT the property grid does not show grid lines until you set its SelectedObject property. The only setting I know you can (instantly) customize about the grid lines is their color. In order to really customize the property grid, of course, you'd either derive your own control class from it and override anything needed, or handle its Paint event, just like with any other control. With a complex control like the property grid that may be quite some effort, though.
Re: PropertyGrid appearence
Quote:
Originally Posted by
Eri523
the property grid does not show grid lines until you set its SelectedObject property.
Yes. Suppose now i have selected a object to propertygrid as
propertyGrid1->SelectedObject = My_img_obj;
and one of the property of My_img_obj (object) class defined as
[Description ("Background color for Alphamap Image Type."), Category ("Image Settings (Alphamap)")]
[Browsable(false)]
property Color BGColor
{
Color get()
{
return bg_color;
}
void set( Color val )
{
bg_color = val;
}
}
each property can be associate to only one Category attribute right ??
Quote:
In order to really customize the property grid, of course, you'd either derive your own control class from it and override anything needed, or handle its Paint event, just like with any other control. With a complex control like the property grid that may be quite some effort, though.
Ya Eri We can do in that way but it will be realy very complex ...
Leave about it ..
can you say how we set or clear this Browsable attribute at run time ..
for example, the above property i want to set at run time I had tried like below
if(platform)
{
AttributeCollection^ attributes = TypeDescriptor::GetProperties(temp) [ "BGColor" ]->Attributes;
attributes[ BrowsableAttribute::typeid ] = BrowsableAttribute::Yes;
}
but i got this error : AttributeCollection doesnt have "Set" method
so in which way i can set this [Browsable(false)] attribute to true at run time?? should we can set this attribute to "true" or "false" at only class definition time??
any idea ??
Re: PropertyGrid appearence
Quote:
Originally Posted by
kumsudheer
so in which way i can set this [Browsable(false)] attribute to true at run time?? should we can set this attribute to "true" or "false" at only class definition time??
any idea ??
While I still maintain the claim that the browsable attributes of the properties of the object attached to the property grid can't be changed at runtime, in the meantime I discovered the PropertyGrid::BrowsableAttributes property that may well help you to do a step in the desired direction. As I understand it, it allows to filter at runtime which properties actually are displayed in the property grid, so it may be used to achieve an effect equivalent to changing the browsable attributes at runtime. You'll probably need to define your own attribute to assign your properties to your custom categories at design time, in order to later filter them by that attribute at runtime. However, of course, that still won't add a new visual level of property categorization to the property grid.
And no, I don't really think deriving your own control class from PropertyGrid is an option for you. I rather mentioned that in response to post #6, made by another forum member.
Re: PropertyGrid appearence
Hi Eri your assumption is right through "BrowsableAttributes" attribute of the property only we can achieve it
find a example code :
Code:
PropertyDescriptorCollection ^ properties = TypeDescriptor::GetProperties(srcscr);
AttributeCollection^ attributes;
if( Any condition)
{
for each(PropertyDescriptor^ Property in properties)
{
if(Property->Category->Contains("(MyOwn)") )
{
attributes = properties[ Property->Name ]->Attributes;
BrowsableAttribute ^ attr =(BrowsableAttribute^)attributes[BrowsableAttribute::typeid];
if(!attr->Browsable)
{
MainForm::Edit_property(attr,true);
}
}
}
}
Edit_property(BrowsableAttribute ^ attr, bool browsable_flag)
{
Type ^ attrType = attr->GetType();
FieldInfo ^ fld = attrType->GetField("browsable",BindingFlags::Instance | BindingFlags::NonPublic);
fld->SetValue(attr,browsable_flag);
}
Guys use this code for your reference to display/hide the properties at run time
Re: PropertyGrid appearence
And make sure sure that while designing your properties in a class this browsable attribute should be always set to "false" like below
Code:
[Description ("Background color for Alphamap Image Type."), Category ("Image Settings (Alphamap)")]
[Browsable(false)]
property Color BGColor
{
Color get()
{
return bg_color;
}
void set( Color val )
{
bg_color = val;
}
}
Re: PropertyGrid appearence
Quote:
Originally Posted by
kumsudheer
Guys use this code for your reference to display/hide the properties at run time
Thanks for posting the code. :thumb: This probably may really be helpful for others who want to do something similar. It would, however, be much more valuable as a reference when posted with code tags. I suggest you edit your posts to add the tags [EDIT:] and ensure proper indentation.
You then can also mark the thread [RESOLVED] using the Thread Tools menu at the top of the thread display, indicating to other users that they may find a solution inside.
Re: [RESOLVED] PropertyGrid appearence
Done Eri. Thanks very much :)