Visual Basic.NET
  Home arrow Visual Basic.NET arrow Page 4 - Exploring the Dialogs Controls in Vb.Net
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Silverlight  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
ASP Web Hosting  
ASP.NET Web Hosting 
Windows Web Hosting
 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
VISUAL BASIC.NET

Exploring the Dialogs Controls in Vb.Net
By: Jayaram Krishnaswamy
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 9
    2006-07-11

    Table of Contents:
  • Exploring the Dialogs Controls in Vb.Net
  • ColorDialog Control
  • OpenFileDialog Control
  • Usage of these Controls

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Exploring the Dialogs Controls in Vb.Net - Usage of these Controls


    (Page 4 of 4 )

    To the project already created add a WebBrowser control. If this is not already in the toolbox, you may add it to the toolbox from Tools -->ChooseToolBoxItems... from the main menu which opens up this next dialog where you can choose the WebBrowser control as shown. When you click OK,  after placing a check mark this control will be added to the toolbox, from where you can drag and drop it onto your form. You should also drag and drop the the three controls, OpenFileDialog, SaveFileDialog, and the FolderBrowserDialog.

    Add one more button to the form, and the finished form should appear as shown in the next picture.

    Now to the click event of the button marked "Show selected file in browser " add the following code:

    'This event opens a dialog from which a folder is chosen. After the folder
    'is chosen, the OpenFileDialog properties such as Filter, InitialDirectory
    'are set and then the ShowDialog() is called. When this window is closed
    'with an 'OK' choice, the WebBrowser navigates to the folder and then on to
    'the filename and gets rendered in the WebBrowser control shown as a large
    'white area in the form. It is assumed that you will browse to get a web
    'page with an *.htm extension. This is then followed by a call to the
    'SaveToLocal() procedure

    Private Sub Button3_Click(ByVal sender As
    System.Object, ByVal e As _ System.EventArgs) Handles Button3.Click FolderBrowserDialog1.ShowDialog() If Windows.Forms.DialogResult.OK Then If Windows.Forms.DialogResult.OK Then OpenFileDialog1.Filter = "(*.htm;*.html)|*.htm;*.html)" OpenFileDialog1.InitialDirectory = _ FolderBrowserDialog1.SelectedPath OpenFileDialog1.ShowDialog() If Windows.Forms.DialogResult.OK Then WebBrowser1.Navigate(FolderBrowserDialog1.SelectedPath _ & "" & OpenFileDialog1.FileName) Call SavetoLocal(OpenFileDialog1.FileName) End If End If End If End Sub
    'this procedure saves the file to a browsed folder. Although the
    'InitialDirectory property has been set, it appears not to accept it.
    'However, you can choose the directory where you want to it to be saved.

    Private Sub SaveToLocal (ByVal str1 As String) SaveFileDialog1.Filter = "(*.htm)|*.htm" SaveFileDialog1.InitialDirectory = "C:" SaveFileDialog1.FileName = str1 SaveFileDialog1.ShowDialog() End Sub

    After you build the project and run the form you will see the following. The WebBrowser control renders the chosen HTML file. The SaveFileDialog will save this file to a chosen location which may be verified.

    Microsoft documentation shows  DialogResult.OK as a result of the Dialog control's ShowDialog() method. However DialogResult is an enum, and the qualifying expression will not be evaluated in their many examples. Windows.Forms.DialogResult.OK is the proper expression to use, as in this tutorial.

    Summary

    All the dialog-box controls that you find under Dialogs in the ToolBox were described, and the examples show some of the methods and properties for these controls. These controls are very useful as they confer a great deal of flexibility in programming. Object browser is an invaluable aid in understanding the hierarchies and the inheritance chains, and you must review it as often as you can. You may also review online help when you want to look for more specifics.


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

       · Being descendents of CommonDialog Controls, these controls should be faimliar to...
     

    VISUAL BASIC.NET ARTICLES

    - Clocks and Countdowns
    - User-defined Functions using Visual Basic Ap...
    - Understanding Object Binding in VBA
    - Mastering the Message Box
    - Testing a Windows Forms Application
    - Using Visual Basic.NET Features to Code a Wi...
    - Correcting Code in a Windows Forms Applicati...
    - Write Readable Code and Comments for Windows...
    - How to Code and Test a Windows Forms Applica...
    - Adding Features to a Windows Forms Applicati...
    - How to Design a Windows Forms Application
    - LINQ to XML Programming Using Visual Basic.N...
    - Understanding Delegates using Visual Basic.N...
    - Create a Sudoku Puzzle Generator using VB.NET
    - Entity Creation and Messaging in a VB.NET Te...





    © 2003-2010 by Developer Shed. All rights reserved. DS Cluster 6 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek