Visual Basic.NET
  Home arrow Visual Basic.NET arrow 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


    (Page 1 of 4 )

    Dialog-box controls are an important part of programs, especially if you expect users to interact with your application. This article explains how to handle several different dialog-box controls.

    Dialogs controls, or more correctly dialog-box controls, are controls that allow the user to interact with the program and retrieve information. They usually pop up when they are called, and allow you to choose a color from a color-pick dialog, or open or save a file through a dialog, and so forth. The user interacts with these at run time, and they present an interface from which the choice is made. They are related to the CommonDialog controls in VB6 and function in a similar way. However they are now based on well defined classes in the System.Windows.Forms name space as we shall see in this tutorial.

    In the course of this tutorial you will see how they fit into the class structure. You will also try to understand their usage by means of an example which uses some of the properties and methods of these controls.

    Accessing the controls in the IDE

    When you create a WindowsApplication project and add a form to the project, you can see these controls in the Toolbox as shown in this picture. Besides these dialog-box controls there are three other dialog-box controls related to printing. These are not covered in this tutorial. While these are built-in controls, it is also possible to create user defined or custom dialog-box controls. Custom dialog-box controls are also not considered.

    These controls are like any other controls; they can be dragged and dropped on the form. However, they are not visible items and find themselves in a tray below the form as shown in this picture, where one each of these controls have been placed on the form, Form1.

    FontDialog Control

    As the name implies, this control, when called up, brings up a familiar dialog box, Font,  from which a variety of choices regarding fonts can be made as shown in this picture. When you click OK to this screen, your font choices will be applied to a string in some part of your program.

    This next picture shows you the class view of the FontDialog class with all the members shown on the right. You can use the New() method to instantiate this object and set its properties and methods. You may notice its hierarchical relationship with the CommonDialog controls.

    Create a WindowsApplication Project, add a form to it and name it suitably. Add a button and a text box control to the form. Drag and drop a FontDialog Control onto the form and it will immediately move to the tray underneath the form. To the click event of the button type in the following code:

    Private Sub Button2_Click(ByVal sender As System.Object, 
    ByVal e As _ System.EventArgs) Handles Button2.Click FontDialog1.ShowDialog()
    'FontDialog window pops-up
    If Windows.Forms.DialogResult.OK Then
    Me.TextBox1.Text = "Viva la Republica!" Me.TextBox1.Font = FontDialog1.Font End If End Sub

    When you build the project and run the program the form pops up. If you now click on the button which has the above code in its click event, the FontDialog window shown earlier pop ups. When you make your choice and click on the OK button your choice will be applied to the text box's font. FontDiaog1.Font has all the selected features. For the picture shown next the choices were, Font: Lucida Console, FontStyle: Bold, Size:11, and Effects: Underline as seen in the next picture. Of course the text box size will not accommodate whatever size you choose, although at design-time the text box size is related to your choice of the font, with the default being Microsoft MS.

    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
    Stay green...Green IT