PC Review


Reply
Thread Tools Rate Thread

Custom Filter for PropertyGrid

 
 
Steven
Guest
Posts: n/a
 
      23rd Mar 2009
I'm trying to set a custom filter for propertygird's FileNameEditor.

//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";
}
}

If I try to override either UITypeEditor or FileNameEditor I get an
unhandled exception:

System.BadImageFormatException: Could not load file or assembly 'MyDLLName,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its
dependencies. The module was expected to contain an assembly manifest.

But if I use the .NET versions it works fine:
[System.ComponentModel.Editor(typeof(System.Windows.Forms.Design.FileNameEditor),
typeof(System.Drawing.Design.UITypeEditor))]

But of course I don't get my filtering.

What's causing the BadImageFormatException when I use my own class?

VS2008/.NET version 3.5/C#
Project: Class Library

Thanks in advance,

Steven


 
Reply With Quote
 
 
 
 
Steven
Guest
Posts: n/a
 
      23rd Mar 2009
One more odd thing, it works fine in DEBUG, but when build a release and run
it, it gives me the dialog for an unhandled exception.

"Steven" <sedison@protronix_nospam_.com> wrote in message
news:(E-Mail Removed)...
> I'm trying to set a custom filter for propertygird's FileNameEditor.
>
> //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";
> }
> }
>
> If I try to override either UITypeEditor or FileNameEditor I get an
> unhandled exception:
>
> System.BadImageFormatException: Could not load file or assembly
> 'MyDLLName, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one
> of its dependencies. The module was expected to contain an assembly
> manifest.
>
> But if I use the .NET versions it works fine:
> [System.ComponentModel.Editor(typeof(System.Windows.Forms.Design.FileNameEditor),
> typeof(System.Drawing.Design.UITypeEditor))]
>
> But of course I don't get my filtering.
>
> What's causing the BadImageFormatException when I use my own class?
>
> VS2008/.NET version 3.5/C#
> Project: Class Library
>
> Thanks in advance,
>
> Steven
>



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using custom TypeConverter outside of PropertyGrid Cartoper Microsoft C# .NET 6 31st Mar 2008 04:01 PM
Custom Dialog Box as PropertyGrid Editor Ron M. Newman Microsoft Dot NET 1 15th Nov 2006 02:15 PM
PropertyGrid, Custom UITypeEditor Romain TAILLANDIER Microsoft Dot NET Framework 1 10th Nov 2006 01:09 PM
Custom PropertyGrid Sort! Özden Irmak Microsoft Dot NET Framework Forms 3 4th May 2005 12:29 AM
PropertyGrid custom editor margoulin Microsoft C# .NET 1 13th Nov 2003 10:39 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:16 PM.