Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / Design Time / April 2004

Tip: Looking for answers? Try searching our database.

EditValue() in UITypeEditor

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Hugh Robinson - 15 Apr 2004 23:38 GMT
I am creating my own UITypeEditor for a class EAFDataBindingsCollection.
The type editor returns UITypeEditorEditStyle.Modal for GetEditStyle()

When I invoke the type editor at design time by clicking on the ... button
for a property of type EAFDataBindingsCollection, then the EditValue()
function is called, but I am having problems downcasting the "value"
argument. In the code below, the
   value is EAFDataBindingsCollection
test returns false, yet the message box shows that "value" actually has this
type!

This is really confusing...
Does anyone know why?

TIA
Hugh Robinson

Here's the code from my UITypeEditor class:

public override object EditValue(ITypeDescriptorContext context,
  IServiceProvider provider,
  object value) {

  IWindowsFormsEditorService edSvc =
   (IWindowsFormsEditorService)
   provider.GetService(typeof(IWindowsFormsEditorService));

  if (value is EAFDataBindingsCollection) {
       // I never get here - even when value *is* of this type!
           EAFDataBindingsCollection coll = (EAFDataBindingsCollection)
value;
       // show the form to edit the collection
       FormEAFDataBindingsCollectionEditor form =
             new FormEAFDataBindingsCollectionEditor(coll);
       if (DialogResult.OK == edSvc.ShowDialog(form)) {
         // return the updated collection;
         return form.EAFDataBindingsCollection;
       }
   } else {
      if (value == null) {
         MessageBox.Show("Value is null");
      } else {
         // This is where I actually end up
         MessageBox.Show("Value has type " + value.GetType().ToString());
      }
  }

  // return the value unchanged
  return value;
  }
}
Hugh Robinson - 16 Apr 2004 22:39 GMT
OK, I found the problem.

(I think...) it was that I had a copy of my DLL in the same directory as
devenv.exe and so the one loaded by VS.NET was an old copy of the DLL.

Hugh Robinson

> I am creating my own UITypeEditor for a class EAFDataBindingsCollection.
> The type editor returns UITypeEditorEditStyle.Modal for GetEditStyle()
[quoted text clipped - 47 lines]
>    }
> }

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.