Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to subclass OpenFileDialog?
Message
 
To
19/01/2005 13:34:32
General information
Forum:
ASP.NET
Category:
Class design
Miscellaneous
Thread ID:
00977889
Message ID:
00979139
Views:
12
(you said)Could you give me an exemple of such an approach with the OpenFileDialog? I've done that in VFP but I am not sure about the proper approach in VB.NET.

(my response)Why do you want to sub-class it in the first place? What functionality did you want to add?

Without knowing those details the simplest form if wrapping the object would be:
using System;
using System.Windows.Forms;

public class OpenDialogWrapper
{
   private OpenFileDialog ofd;

   public OpenFileDialog
   {
      // The public getter will allow for everyone
      // to access the OpenFileDialog object if needed
      // or you can provide other public properties to
      // specific functionality you only want to give
      // access...
      get{return this.ofd;)
   }

   public string FileName
   {
      // Add getters and setter for
      // properties of the wrapped object
      // if you make the OpenFileDialog
      // a private member
      get{return this.ofd.FileName;}
      set{this.ofd.FileName = value;}
   }

   public OpenDialogWrapper()
   {
      // Add constructor code here...
   }

   public virtual void ExtendYourFunctionalityMethod()
   {
      // I think virtual is overridable in VB
      // Add extended functionality here
      // Add more methods to add functionality
   }
}
Sorry it's not VB code - I feel clumsy writing VB.NET since I'm not totally familiar with the syntax so I provided the sample in C#. Maybe someone can
interpet the code if you have difficulty reading it.

But basically you provide a class that you can inherit from, hide the object you're wrapping (or expose it through a public property), and add the necessary functionality you want.

Hope it helps!!!
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform