Visual Basic.NET
  Home arrow Visual Basic.NET arrow Page 2 - 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 - ColorDialog Control


    (Page 2 of 4 )

    Again as the name suggests, when this control is called up, it will show a color-pick dialog, Color, where you can pick a color that can be applied to the object's color related properties. This can be the backcolor of a text box for example, or the form's backcolor, or forecolor, and so forth.

    The next picture shows the class view of the ColorDialog class. Again you can trace it back to the CommonDialog control in the inheritance chain. There are many properties, out of which only the Color() property is used. The ShowDialog() is however inherited from the CommonDialog.

    Now to the above project add another button, and after dragging and dropping a ColorDialog control onto the form, add the following code to the click event of the button:

    Private Sub Button1_Click(ByVal sender As System.Object, 
    ByVal e As _ System.EventArgs) Handles Button1.Click ColorDialog1.ShowDialog() If Windows.Forms.DialogResult.OK
    Then Me.TextBox1.BackColor = ColorDialog1.Color End If End Sub

    The first line of code, ColorDialog1.ShowDialog() pops up the Color pick window shown earlier. When you make the choice and click OK, the Windows form gets the message and applies the ColorDialog's Color() property (the color chosen) to the Backcolor property of the text box control. When you build and run the form, it shows with the two buttons, one for the font and one for the color. Clicking the Font button creates some text in the text box, and by clicking the color button and applying a light blue color you will see the following.

    FolderBrowserDialog, OpenFileDialog and SaveFileDialog Controls

    These dialogs will be briefly discussed, and in the last part of the project all these controls will be used, which accomplishes the following. The FolderBrowserDialog Control will open a browser from which a folder will be chosen. The OpenFileDialog will open a file from the folder and will be passed on to a web browser control to display a web page. The chosen file can then be saved to a chosen location using the SaveFileDialog control.

    FolderBrowserDialog Control

    When you call up this control it will pop up a Browse For Folder dialog as shown in the next picture, from which you can choose a folder, a sub-folder and any other nested folder. The path to this folder is now captured in this object's SelectedPath() property which can be accessed by code.

    This next picture shows you the class view of the FolderBrowserDialog class and its members in the right panel. You can instantiate using the NEW() keyword.

    More Visual Basic.NET Articles
    More By Jayaram Krishnaswamy


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

    VISUAL BASIC.NET ARTICLES

    - 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...
    - Movement and Player Statistics in a VB.NET T...





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