OpenfileDialogBox file type change event handler

Posted on 2009-04-27
Last Modified: 2013-12-26
Hi all

I need to manipulate the standard openfiledialog box tool.I need it to respond and handle an event when i change the file type.

I will have a couple of file type choices in standard openfiledialogbox and when i click to sql file type ,i need an other screen pop up.

How can i do that, in VB?

Question by:AGullen2
    LVL 39

    Expert Comment

    The OpenFileDialog class is sealed, which means you cannot inherit from it. Instead, you can inherit from the FileDialog class and override the HookProc to react to messages that are send. This is however not easy to do, unless you are well trained in windows messaging and window-subclassing.

    Note that if you would work on Vista, you could use the FileDialogNative.IFileDialogEvents, but I'm not sure how to work with them and they may not be accessible easily (internal static members).

    Alternatively, create your own dialog, so you can do whatever you like to do. This seems like more work, but in the end will prove easier to do.

    -- Abel --
    LVL 39

    Accepted Solution

    The following codeproject article is on the subject, but uses C++: This example uses C# and is more readable, possibly:

    Also, if you own the book Visual Basic's programmers guide to win32 API, you can find some examples in there too.

    On E-E it has earlier been dismissed as "serious magic":

    This is just one of those annoyances that the .NET environment gives us. It does a lot for us, but sometimes you just want it a little different and all of a sudden you find yourself programming against a sealed class...

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
    You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
    Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
    Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now