Visual Basic.NET
  Home arrow Visual Basic.NET arrow Manipulating Forms with the Windows Forms ...
Iron Speed
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  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Dedicated Servers 
Download TestComplete 
Windows Web Hosting
 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
eWeek
 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

Manipulating Forms with the Windows Forms Library
By: O'Reilly Media
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 2
    2007-02-22

    Table of Contents:
  • Manipulating Forms with the Windows Forms Library
  • 4.11 Attaching a Control to the Edge of a Form
  • 4.12 Moving or Resizing Controls as a Form Resizes
  • 4.13 Limiting the Sizing of a Form

  • 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
     
     
    Iron Speed
     
    ADVERTISEMENT

    Free Web 2.0 Code Generator! Generate data entry and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!

    Manipulating Forms with the Windows Forms Library
    (Page 1 of 4 )

    In this third part of a four-part series, you will learn how to use .NET's Windows Forms Library to make forms and controls interact with each other. This article is excerpted from chapter four of the Visual Basic 2005 Cookbook, written by Tim Patrick and John Clark Craig (O'Reilly; ISBN: 0596101775). Copyright © 2006 O'Reilly Media, Inc. All rights reserved. Used with permission from the publisher. Available from booksellers or direct from O'Reilly Media.

    4.10 Remembering a Form’s Position Between Uses

    Problem

    You would like the position of a form to be retained between exiting the application (or closing that form) and the next time you access that same form.

    Solution

    Sample code folder: Chapter 04\RememberFormPosition

    Tie the form’sLocationproperty to a member of theMy.Settingsobject. You do this using the form’s application-setting property bindings.

    Create a new Windows Forms application. Access the Project Properties window through the Project -> WindowsApplication1 Properties (or similar) menu command. Select the Settings tab in this window, as shown in Figure 4-5.


    Figure 4-5.  The Settings tab of the Properties window

    In the first row of the Settings grid, set the Name field toMainFormLocation, and selectSystem.Drawing.Pointin the Type field (Figure 4-6). Close the Project Properties window.


    Figure 4-6.  The added MainFormLocation property

    Back onForm1, expand its(ApplicationSettings)property. One of the subproperties should beLocation. Change its value toMainFormLocation.

    The program is ready to use. Run it, and move the form to a conspicuous location. Then exit the program. When you run the program again, the form will be where you moved it.

    Discussion

    If, when you expand the (ApplicationSettings) property, you don’t see theLocationsubproperty, use the(PropertyBinding)subproperty instead. Click on the “...” button in its value area to display the “Application Settings for ‘Form1’” dialog. Locate theLocationentry in the form’s settings list, and set its value toMainFormLocation, as shown in Figure 4-7.


    Figure 4-7.  The Application Settings dialog for Form1 

    Any settings added to the Settings tab in the Project Properties window appear as members of theMy.Settingsobject. In this recipe’s case, you get a new property of typeSystem.Drawing.Pointwith the nameMy.Settings.MainFormLocation. You can access this property as needed in your code.

    Another way to add a control-linked setting is to skip the trip to the Project Properties’ window’s Settings panel, and add the new setting directly from the control’s list of properties. When you select the(ApplicationSettings)property for the form or control and bring up the Application Settings dialog (Figure 4-7), if you click the drop-down button in the second column for any property, one of the choices that appears is “(new).” Clicking this link brings up the New Application Setting dialog, where you can enter the name and starting value of a new setting. The new property automatically obtains the right data type for the linked field. Figure 4-8 shows this method in action.


    Figure 4-8.  Adding a new setting for the form's Location property 

    More Visual Basic.NET Articles
    More By O'Reilly Media


       · This article is an excerpt from the book "Visual Basic 2005 Cookbook," published by...
     

    Buy this book now. This article is excerpted from chapter four of the Visual Basic 2005 Cookbook, written by Tim Patrick and John Clark Craig (O'Reilly; ISBN: 0596101775). Check it out today at your favorite bookstore. Buy this book now.

    VISUAL BASIC.NET ARTICLES

    - Types of Operators in Visual Basic
    - Operators
    - Understanding Custom Events using Visual Bas...
    - Polymorphism using Abstract Classes in Visua...
    - Shadowing using Shadows in Visual Basic.NET ...
    - Overloading and Overriding in Visual Basic.N...
    - More on Controlling Windows Fax Services Usi...
    - Programmatically Controlling Windows Fax Ser...
    - Focusing on Forms and Menus in Visual Basic
    - Manipulating Forms with the Windows Forms Li...
    - Basics of the Windows Forms Library
    - Forms, Controls, and Other Useful Objects
    - Implementing OOP to Develop Database Oriente...
    - Using Themes and Skins for Personalization w...
    - A Deeper Look at Personalization using Visua...




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway