Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 26-03-2009
Member
 
Join Date: Feb 2009
Posts: 39
Exclamation How to set the Custom Filters for PropertyGrid

Hello,

I have .Net project in that I had to make customization in the Property Grid window so is it possible to apply Custom Filters for propertyGrid and if this is possible then please let me know to achieve this.

Thanks in Advace
Reply With Quote
  #2  
Old 26-03-2009
Member
 
Join Date: Jan 2006
Posts: 211
Re: How to set the Custom Filters for PropertyGrid

I'm trying to set a custom filter for propertygird's FileNameEditor.

Code:
//property
[DisplayName("File Path")]
[Category("Video Settings")]
[Description("The path to the file to be played.")]
[System.ComponentModel.Editor(typeof(MovieFileNameEditor),
typeof(UITypeEditor))]
public string FilePath
{
  get { return _FilePath; }
  set { _FilePath = value; }

}

//FileNameEditor override
internal class MovieFileNameEditor :
System.Windows.Forms.Design.FileNameEditor
{
    protected override void InitializeDialog(OpenFileDialog openFileDialog)
    {
        base.InitializeDialog(openFileDialog);

        openFileDialog.Filter = "Movie Files (*.avi, *.mpeg,
*.mpg)|*.avi;*.mpeg;*.mpg";
        openFileDialog.Title = "Select Movie File";
    }

}
Reply With Quote
  #3  
Old 26-03-2009
Member
 
Join Date: Dec 2008
Posts: 161
Re: How to set the Custom Filters for PropertyGrid

Suppose your SelectedObject is a TextBox, and you want to display in a PropertyGrid only the "Size" property of your TextBox. As the PropertyGrid control is, it is not possible.

you may continue passing to the PropertyGrid.BrowsableAttributes property a collection of attributes like "PropertyNameAttribute". But unfortunately, such attributes don't exist.

I propose another approach: using a wrapper object that contains the object you want to display in the PropertyGrid. This wrapper will be passed to the PropertyGrid, instead of the object itself. So, the PropertyGrid will not directly display the object's properties, but the wrapper's ones. In this case, you need to subclass the PropertyGrid with a new control that overrides the SelectedObject property. That's exactly what I did, while writing the FilteredPropertyGrid control. This control is inherited from PropertyGrid and works the same way. I just added these useful properties:
  • BrowsableAttributes: overridden from PropertyGrid.
  • HiddenAttributes: all the properties that have the attributes contained in the collection are hidden.
  • BrowsableProperties: all the properties contained in the collection are displayed.
  • HiddenProperties: all the properties contained in the collection are not displayed.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "How to set the Custom Filters for PropertyGrid"
Thread Thread Starter Forum Replies Last Post
How to create a Custom Capsule that is a Custom Firmware with root on lacie 2big Network drive Kane89 Networking & Security 8 06-05-2012 12:21 PM
Hotmail Filters Disappeared Apalachee Technology & Internet 6 04-06-2010 12:39 AM
Using filters in DVD Rebuilder Bower Windows Software 5 03-05-2010 09:47 AM
What Filters are Available in PHP? N I C K Software Development 4 28-02-2010 05:12 AM
Cable filters and if anyone has used one before? NetTalk Off Topic Chat 4 13-10-2009 05:18 PM


All times are GMT +5.5. The time now is 02:56 AM.