Home

The Properties of Windows Controls

 

Common Properties

 

Introduction to Windows Controls

A Windows control, also called a control, is an object that can be seen on the form of an application and that allows a user to interact with the computer. There are some characteristics that all controls share. Because there are many behavioral differences among the various types of controls, there are some other characteristics that only some controls have. Still, to provide a common list of features that Windows controls share, the .NET Framework provides a class named Control:

type Control =  
    class 
        inherit Component 
        interface IDropTarget 
        interface ISynchronizeInvoke 
        interface IWin32Window 
        interface IComponent 
        interface IDisposable 
        interface IBindableComponent 
    end

The Control class derives from another control named Component:

type Component =  
    class 
        inherit MarshalByRefObject 
        interface IComponent 
        interface IDisposable 
    end

The main job of the Component class is to manage the computer memories that the Windows controls occupy while an application is active. Other than that, the Control class is equipped with common properties, methods, and events that Windows control need.

The Tag of a Windows Control

Every Windows control of the .NET Framework has a property named Tag:

member Tag : Object with get, set

This property can hold any value you want and it can mean anything you want. If you want to use this property, assign any value of your choice to it and then use it.

Parenting a Control

A control is referred to as parent if it can host or it can contain other controls. A parent control is also referred to as a host or container. To support this characteristic, the Component class, which is the parent of the Control class, is equipped with a property named Container that implements an interface named Container that implements an interface named IContainer:

member Container : IContainer with get

The property allows a control container to host its controls and the IContainer interface takes care of any related logistics issues.

As you know already, every Windows control is represented by a class in the .NET Framework. The class of every control that can act as parent has a property named Controls which is of type ControlCollection:

member Controls : Control.ControlCollection with get

That property represents a class that has a method named Add. Based on this, to indicate that the parent control will host a container, pass that control to the Controls.Add() method. So far, we have only used the form and its Form class as container, but there are other controls parents.

The Location of a Control

As seen in Lesson 3, the location of a control is the place where it is positioned. This is with regards to its parent control. So far, we were using the Left and the Top properties to specify it. We saw that, based on the Left and the Top properties, the location of a control could be illustrated as follows:

Location

As an alternative, to let you specify the location of a control with one value, each class of the Windows controls is equipped with a property named Location:

member Location : Point with get, set

This Location property is based on the Point structure. This allows you to use one of the constructors of the Point structure, namely the Point(x : int, y : int) contructor, to specify the location of a control. Here is an example:

open System
open System.Drawing
open System.Windows.Forms

let Exercise : Form = new Form()
let btnSubmit : Button = new Button()

btnSubmit.Text <- "Submit"
btnSubmit.Location <- new Point(100, 40)

Exercise.Controls.Add(btnSubmit)
do Application.Run(Exercise)

You can also use an existing Point object and assign it to the Location property of the control. Here is an example:

open System
open System.Drawing
open System.Windows.Forms

let Exercise : Form = new Form()
let btnSubmit : Button = new Button()

btnSubmit.Text <- "Submit";

let mutable pt = new Point()
pt.X <- 100
pt.Y <-  40
btnSubmit.Location <- pt

Exercise.Controls.Add(btnSubmit)
do Application.Run(Exercise)

You can also retrieve the location of a control and store it in a Point object. To do this, you can simply assign the Location property of a control to a Point object. Here is an example:

open System;
open System.Drawing;
open System.Windows.Forms;

let Exercise : Form = new Form()
let btnSubmit : Button = new Button();

btnSubmit.Text <- "Submit";

btnSubmit.Location <- new Point(100, 40);
        
let pt = btnSubmit.Location

Exercise.Controls.Add(btnSubmit);
Application.Run(Exercise);

You can use the location of one control as a reference to position another control. To do this, retrieve the location of one control and change either its X and/or its Y values to position the new control. Here is an example:

open System;
open System.Drawing;
open System.Windows.Forms;

let Exercise : Form = new Form()
let btnSubmit : Button = new Button();
let txtEmployeeName : TextBox = new TextBox();

btnSubmit.Text <- "Submit";

btnSubmit.Location <- new Point(100, 40);
        
let pt = btnSubmit.Location;

txtEmployeeName.Location <- new Point(pt.X, pt.Y + 32);

Exercise.Controls.Add(btnSubmit);
Exercise.Controls.Add(txtEmployeeName);

Application.Run(Exercise);

This would produce:

Remember that you can include the properties and their values in the parentheses of the class used to add a control to your application. This also applies to the Location property. Here is an example:

open System
open System.Drawing
open System.Windows.Forms

let Exercise : Form = new Form()

let btnSubmit : Button = new Button(Location = new Point(100, 40), Text = "Submit")
Exercise.Controls.Add(btnSubmit)

do Application.Run(Exercise)

The Size of a Control

The size of a control is the combination of its width and its height.

Size Representation

So far, we managed the width and the height using the Width and the Height properties of every control. To support a common way to manage both values as one, the classes of the controls are equipped with a property named Size:

member Size : Size with get, set

As you can see, this property is of type Size. Normally, every control has a default size specified in its class. Still, if you want or need to specify the width and the height of a control, you can create a Size object using one of its constructors, namely the Size(width : int, height : int) constructor, and assign it to the Size property. Here is an example:

open System
open System.Drawing
open System.Windows.Forms

let exercise : Form = new Form()

let btnSubmit : Button = new Button()

btnSubmit.Text <- "Submit"
btnSubmit.Location <- new Point(100, 40)
btnSubmit.Size <- new Size(80, 32)

exercise.Controls.Add(btnSubmit)

do Application.Run(exercise)

You can include the size in the parentheses of the class used to add a control to your application. Here is an example:

open System
open System.Drawing
open System.Windows.Forms

let Exercise : Form = new Form()

let btnSubmit : Button = new Button(Location = new Point(100, 40), Size = new Size(80, 32), Text = "Submit")
Exercise.Controls.Add(btnSubmit)

do Application.Run(Exercise)

The Client Size of a Control

A Windows control has a body, which is the area from its left border to its right border and from its top border to its bottom border. To represent this aspect, the Control class is equipped with a property named ClientSize:

member ClientSize : Size with get, set

All visual controls inherit this property. You can use it to specify the size of a control. Here is an example:

open System
open System.Drawing
open System.Windows.Forms 

let exercise = new Form(Width = 320, Height = 353, Text = "Exercise")

let lblMessage = new Label(Text = "Something", Left = 12, Top = 15)
lblMessage.ClientSize <- new Size(Height = 50, Width = 200)

exercise.Controls.Add lblMessage

do Application.Run exercise

The client area is actually used for any object that is positioned within the area occupied by the control. That's how this property is used on controls that serve as parents. This is the case for the form. Here is an example:

open System
open System.Drawing
open System.Windows.Forms 

let exercise = new Form(Text = "Exercise")
exercise.ClientSize <- new Size(Width = 180, Height = 100)

let lblMessage = new Label(Text = "Something", Left = 12, Top = 15)
lblMessage.ClientSize <- new Size(Height = 50, Width = 200)

exercise.Controls.Add lblMessage

do Application.Run exercise

Remember that you can include the properties in the parentheses of the constructor of the class used to create the control. Here are examples:

open System
open System.Drawing
open System.Windows.Forms 

let exercise = new Form(Text = "Exercise", ClientSize = new Size(180, 100))

let lblMessage = new Label(Text = "Something", Left = 12, Top = 15, ClientSize = new Size(100, 60))

exercise.Controls.Add lblMessage

do Application.Run exercise

To know the amount of space that a control is using, you can access its ClientSize property.

The Bounding Area of a Control

Every visual control in an application has a location and a size. To be able to recognize the location and the size of a control, the class of every control is equipped with a property named Bounds. This property is of type Rectangle:

abstract Bounds : Rectangle with get, set
override Bounds : Rectangle with get, set

Therefore, at any time, to get the location and the size of a control, you can access its Bounds property, which produces a Rectangle value.

Anchoring a Control

If you position a (visual) control on a container and if the control is on the top left section of the container, when the user resizes the form, the control's position would appear static: it would not move. This could be a concern if the control is positioned on the right, the bottom or the lower right sections of the container. When the user resizes the form, the control's position would not be updated. Sometimes you will want the control to have the same location and/or distance with regards to the bottom, the right, and/or the lower right corners of the form.

The ability to manage a control or a group of controls' location and size when the user resizes it is done using the Anchor property. The Anchor property is controlled by the AnchorStyles enumeration. By default, when you add a control to a form, its position is relative to the top left corner of its container. You can also set the control's position with regards to its container's right and bottom borders. The Anchor property can be used to "glue" one border of a control to its parent using one of the following values:

Bottom: The control bottom border will be the same even if the parent is heighten or shrunk

  Anchoring a Control Anchoring a Control

Left: The control left border will be the same even if the parent is widened or narrowed

Anchoring a Control Anchoring a Control

None: No anchoring is applied

Anchor Anchoring a Control

Right: The control right border will be the same even if the parent is widened or narrowed

Anchoring Anchoring a Control

Top: The control top border will be the same even if the parent is heightened or shrunk

Anchoring a Control Anchoring a Control

In the same way, you can combine AnchorStyles values to "glue" one or more corners of a control to its parent when the parent is resized.

Combining Members of an Enumerated Property

Sometimes, just using one member of an enumerated property will not be enough. You may have to combine members to get a combined behavior. The combination operation of two or more enumeration members is done using the bitwise OR operator, which is |||.

Docking a Control

When a control is added to a host, to let you attach the control to a border or to a corner of its parent, the Control class is equipped with the Dock property. This property is managed through the DockStyle enumeration. Its members are:

Bottom: The control will be attached to the bottom border of its parent:

A control docked bottom

Fill: The control will use the whole client area of its parent.

Left: The control will be attached to the left border of its parent:

A control docked right

None: The control will be kept where it was positioned on the parent.

Right: The control will be attached to the right border of its parent:

Anchoring a Control

Top: The control will be attached to the top border of its parent:

Anchoring a Control

To programmatically specify the docking option of a control, access its Dock property and assign the desired member of the DockStyle enumeration. Here is an example:

open System
open System.Drawing
open System.Windows.Forms

let exercise  = new Form()
let btnSubmit = new Button()

btnSubmit.Text <- "Submit"

btnSubmit.Location <- new Point(100, 40)
        
let pt = btnSubmit.Location

btnSubmit.Size <- new Size(100, 60)
btnSubmit.Dock <- DockStyle.Right

exercise.Controls.Add btnSubmit

do Application.Run exercise
 
   
 

Aesthetic Aspects of a Control

 

Background Color

Controls used on Microsoft Windows are painted using a color known as Control. If you don't like the default color that paints the background of a control, to let you control it, the class of every control is equipped with a property name BackColor. The values or colors are based on the Color structure.

To specify the background color of a control, access its BackColor property and assign it the desired member of the Color enumeration. Here is an example:

open System
open System.Drawing
open System.Windows.Forms

let exercise  = new Form()
let btnSubmit = new Button()

btnSubmit.Text <- "Submit"

btnSubmit.Location <- new Point(100, 40)
        
let pt = btnSubmit.Location

btnSubmit.Size <- new Size(100, 60)
btnSubmit.BackColor <- Color.Aquamarine

exercise.Controls.Add btnSubmit

do Application.Run exercise

Background Image

Instead of a color, you may want to fill the control with a picture. To let you do this, the classes of the controls are equipped with a property named BackgroundImage. This property is based on the Image class that is equipped with a method named FromFile that takes a string as argument: the path to the picture file. Here is an example:

open System
open System.Drawing
open System.Windows.Forms

let exercise : Form = new Form()
let pnlPicture : Panel = new Panel()

pnlPicture.Dock <- DockStyle.Fill;
pnlPicture.BackgroundImage <- Image.FromFile(@"C:\Pictures\House.jpg")

exercise.Controls.Add pnlPicture

do Application.Run exercise

Border Style

Some controls display a border when they are drawn and some others don't. Consider the following:

Some of the controls allow you to specify a type of border you want to show surrounding the control. This characteristic is controlled by the BorderStyle property, which is based on BorderStyle enumeration. Its members are:

Value Example
Fixed3D Border Style
FixedSingle Border Style
None Border Style

To specify the border style of a control, access its BorderStyle property and assign it the desired BorderStyle member. Here is an example:

open System
open System.Drawing
open System.Windows.Forms

let exercise  = new Form()
let pnlViewer = new Panel(Location = new Point(12, 12), Size = new Size(150, 80))

pnlViewer.BorderStyle <- BorderStyle.Fixed3D
pnlViewer.BackColor <- Color.LightBlue

exercise.Controls.Add pnlViewer

do Application.Run exercise
         

API Characteristics of Windows Controls

 

Tab Ordering

A user can navigate through controls using the Tab key. When that key has been pressed, the focus moves from one control to the next. By their designs, not all controls can receive focus and not all controls can participate in tab navigation. Even controls that can receive focus must be primarily included in the tab sequence.

The participation to tab sequencing is controlled by the Boolean TabStop property. Every visual control that can receive focus is already configured to have this property set to true. If you want to remove a control from this sequence, set its TabStop value to false.

If a control has the TabStop property set to true, to arrange the navigation order of controls, you have two main options. The value of a tab sequence is controlled by the TabIndex property. The value must be a positive short integer.

Control's Visibility

A control is referred to as visible if it can be visually located on the screen. A user can use a control only if he or she can see it. As a programmer, you have the role of deciding whether a control must be seen or not and when. The visibility of an object is controlled by the its Visible Boolean property. This is a Boolean property.

Control's Availability

For the user to use a control, it must allow operations on it. For example, if a control is supposed to receive text, the user can enter characters in it only if this is made possible. To make a control available to the user, the object must be enabled. The availability of an object is controlled by the Boolean Enabled property.

An enabled control displays its text or other characteristics in their normal settings. If you want to disable a control, set its Enabled property to false. In the following picture, a text box and a button are disabled:

Enabled

To programmatically find out whether a control is enabled or not, check its Enabled property.

Allowing Drag n' Drop Operations

Drag n' drop is the ability to drag an object or text from one location or object to another. This is a significant operation in computer use. Although Microsoft Windows fully supports drag n' drop operations, because the operating system cannot predict how the operations should be carried, you must write code.

Various controls support drag n' drop operations. While most controls support them, it is not always realistic to implement the operations on every control. This means that you will have to decide when, how, and what controls of your application will need to allow the user do drag what and drop it where.

A control that allows drag n' drop operations is equipped with a Boolean property named AllowDrop. When you set this property to true, it means the user can either drag something from it or drop something on it. After setting this property, you must write code.

Text-Based Properties

 

Auto-Sizing a Control

When you specify the text of text-based control (such as the label), it uses a default width to contain its text. If the text, also called caption, is shorter than the default width, the control displays that text and the remaining area is left empty. Here is an example:

open System
open System.Windows.Forms

// Form: Convenience Store
let convenienceStore = new Form(Width = 200, Height = 85, Text = "Convenience Store")

// Label: First Name
let lblFirstName = new Label()
lblFirstName.Left <- 18
lblFirstName.Top  <- 18
lblFirstName.Text <- "First Name:"
convenienceStore.Controls.Add lblFirstName

// Text Box: First Name
convenienceStore.Controls.Add(new TextBox(Left = 82, Top = 16, Width = 80))

do Application.Run convenienceStore

This would produce:

Auto-Sizing a Control

So far, to resize a control, we had to play with the Width property. To let the compiler figure out how much space is necessary to display the text of such a control, their class includes a Boolean property named AutoSize. For some controls, the default value of this property is false. For some other controls, this property is defaulted to true. Therefore, to specify the auto-sizing option of a control, access its AutoSize property and assign it the desired Boolean value. Here is an example:

open System
open System.Windows.Forms

// Form: Convenience Store
let convenienceStore = new Form(Width = 200, Height = 85, Text = "Convenience Store")

// Label: First Name
let lblFirstName = new Label()
lblFirstName.Left <- 18
lblFirstName.Top <- 18

lblFirstName.AutoSize <- true

lblFirstName.Text <- "First Name:"
convenienceStore.Controls.Add lblFirstName

// Text Box: First Name
convenienceStore.Controls.Add(new TextBox(Left = 82, Top = 16, Width = 80))

do Application.Run convenienceStore

This would produce:

Auto-Sizing a Control

The Content Alignment of a Control

If a control can be resized, or it has been configured to be sizable, you can specify in what part of its confined borders the text should display. This characteristic is controlled by a property named TextAlign. The TextAlign property is based on an enumeration named ContentAlignment. The members of this enumeration have the following names: BottomCenter, BottomLeft, BottomRight, MiddleCenter, MiddleLeft, MiddleRight, TopCenter, TopLeft, and TopRight. Because controls have different behaviors, not all of them use all these members. Still, the common description is the same.

The members and results of this enumeration used on a button-based control (such as a button, a check box, or a radio button) or a label are as follows:

TopLeft TopCenter TopRight
TopLeft TopCenter TopRight
MiddleLeft MiddleCenter MiddleRight
MiddleLeft MiddleCenter MiddleRight
BottomLeft BottomCenter BottomRight
BottomLeft BottomCenter BottomRight

To specify the text alignment of a control, access its TextAlign property and assign it the desired member of the ContentAlignment enumeration. Here is an example:

open System
open System.Drawing
open System.Windows.Forms

let exercise  = new Form()
let btnSubmit = new Button()

btnSubmit.Text <- "Submit"

btnSubmit.Location <- new Point(100, 40)
        
let pt = btnSubmit.Location

btnSubmit.Size <- new Size(100, 60)

btnSubmit.TextAlign <- ContentAlignment.BottomRight

exercise.Controls.Add btnSubmit

do Application.Run exercise

The Multi-Line Text Boxes

The classic text box is used to display a single line of text. To allow you to display various lines of text, both the TextBox and the RichTextBox classes are equipped with a Boolean property named Multiline:

abstract Multiline : bool with get, set
override Multiline : bool with get, set

The Multiline property is set to false by default value on the text box. If you want a text box to use multiple lines, set it to true. Here is an example:

open System
open System.Drawing
open System.Windows.Forms 

let exercise = new Form(Width = 320, Height = 153, Text = "Restaurant Presentation")

let txtIntroduction = new TextBox(Size = new Size(290, 100), Location = new Point(12, 12))
txtIntroduction.Multiline <- true
exercise.Controls.Add txtIntroduction

let introduce() =
    "Welcome to Four-Corner restaurant. We serve the best exotic meals in the region. " +
    "Our selection includes soups, sauce, meals, and appetizers. During the week, " +
    "from Monday to Friday, we serve the Lunch Special when the prices of most of " +
    "meals are reduced. Come and try our tastes. You will be delighted."

let description = Func<string>(introduce)

let result = description.Invoke()

txtIntroduction.Text <- "Restaurant Introduction: " + Environment.NewLine + result

do Application.Run exercise

This would produce:

The Multi-Line Text Boxes

The Multiline property is set to true by default value on the rich ext box. Unless you have some curious valid reason, you should not change this property on the rich text box.

List-Based Properties of Collections Controls

   

The List View

The .NET Framework proposes many controls whose main purpose is to display a collection of items. Of course, there are different types of controls with various goals. One of the controls is the list view. It is used to display its lists with various options. One of the options consists of using columns to organize the values of the list view. To let you show those columns, the ListView class is equipped with a property named View and that is based on an enumeration of the same name:

member View : View with get, set

The members of the View enumeration are: Details, LargeIcon (the default), List, SmallIcon, and Tile. In order to display more information about the values of the list view, set the View property to Details. Other valuable properties of the list view are GridLines and FullRowSelect which are Boolean-based.

The list view control is actually made of various lists. One of its list is for the columns in the top area of the control when it displays in detail view. The columns are held by a property named Columns that is based on a collection named ColumnHeaderCollection:

member Columns : ListView.ColumnHeaderCollection with get

Each column is based on a class named ColumnHeader. The class is equipped with all necessary properties and method for a column:

  • Text: This is the text that displays on the column header
  • Width: This is width of the column header
  • TextAlign: This characteristic specifies how the text of the column header should be positioned, to the left, the center, or the right

You can create the columns individually and add each by calling the ListView.ColumnHeaderCollection.Add() method to which you would pass a ColumnHeader object. This method returns an integer. Here are examples:

open System
open System.Drawing
open System.Windows.Forms 

let apartmentRental = new Form(Width = 345, Height = 178, Text = "Apartment Rental")

let lvwApartments : ListView = new ListView(Location = new Point(12, 12), Size = new Size(312, 124), GridLines = true, View = View.Details, FullRowSelect = true)

let mutable col = lvwApartments.Columns.Add("Apartment #", 75)
col <- lvwApartments.Columns.Add("Beds", 40, HorizontalAlignment.Right)
col <- lvwApartments.Columns.Add("Baths", 40, HorizontalAlignment.Right)
col <- lvwApartments.Columns.Add("Status", 75)
col <- lvwApartments.Columns.Add("Rate/month", 75, HorizontalAlignment.Right)

apartmentRental.Controls.Add lvwApartments

do Application.Run apartmentRental

As an alternative, you can call the ListView.ColumnHeaderCollection.AddRange() method. Here is an example:

open System
open System.Drawing
open System.Windows.Forms 

let apartmentRental = new Form(Width = 345, Height = 178, Text = "Apartment Rental")

let lvwApartments : ListView = new ListView(Location = new Point(12, 12), Size = new Size(312, 124), GridLines = true, View = View.Details, FullRowSelect = true)

lvwApartments.Columns.AddRange([| new ColumnHeader(Text = "Apartment #", Width = 75);
                                  new ColumnHeader(Text = "Beds", Width = 40, TextAlign = HorizontalAlignment.Right);
                                  new ColumnHeader(Text = "Baths", Width = 40, TextAlign = HorizontalAlignment.Right);
                                  new ColumnHeader(Text = "Status", Width = 75);
                                  new ColumnHeader(Text = "Rate/month", Width = 75, TextAlign = HorizontalAlignment.Right) |])

apartmentRental.Controls.Add lvwApartments

do Application.Run apartmentRental

This would produce:

The Columns of a List View

Probably the most important collection in a list view is its list of items. They are stored in a property named Items, which is based on a class named ListViewItemCollection:

type ListViewItemCollection =  
    class 
        interface IList 
        interface ICollection 
        interface IEnumerable 
    end

Each item of a list view is based on a class named ListViewItem. That class has various constructors for different ways to create items. This is because an item of a list view has many options. Unlike the collections of simple list-based controls (combo box, list box, domain up-down, etc), an item of a list view holds its own collection of items. Therefore, the ListViewItem class is equipped with a constructor that takes a collection of items. You can create the collection in the parentheses of the constructor and pass that constructor to the ListView.ListViewItemCollection.Add() method:

abstract Add :
        value:ListViewItem -> ListViewItem
override Add :
        value:ListViewItem -> ListViewItem

This method returns the item that was added to the collection. Here are examples of creating and adding items to a list view:

open System
open System.Drawing
open System.Windows.Forms 

let apartmentRental = new Form(Width = 345, Height = 178, Text = "Apartment Rental")

let lvwApartments : ListView = new ListView(Location = new Point(12, 12), Size = new Size(312, 124), GridLines = true, View = View.Details, FullRowSelect = true)

let mutable col = lvwApartments.Columns.Add("Apartment #", 75)
col <- lvwApartments.Columns.Add("Beds", 40, HorizontalAlignment.Right)
col <- lvwApartments.Columns.Add("Baths", 40, HorizontalAlignment.Right)
col <- lvwApartments.Columns.Add("Status", 75)
col <- lvwApartments.Columns.Add("Rate/month", 75, HorizontalAlignment.Right)

let mutable lviApartment = lvwApartments.Items.Add(new ListViewItem([| "101"; "1"; "1"; "Available";  "945.00" |]))
lviApartment <- lvwApartments.Items.Add(new ListViewItem([| "102"; "3"; "2"; "Occupied";  "1450.00" |]))
lviApartment <- lvwApartments.Items.Add(new ListViewItem([| "103"; "2"; "1"; "Available"; "1275.00" |]))
lviApartment <- lvwApartments.Items.Add(new ListViewItem([| "104"; "1"; "1"; "Not Ready";  "945.00" |]))
lviApartment <- lvwApartments.Items.Add(new ListViewItem([| "105"; "2"; "2"; "Occupied";  "1325.00" |]))
lviApartment <- lvwApartments.Items.Add(new ListViewItem([| "106"; "3"; "1"; "Available"; "1385.00" |]))
lviApartment <- lvwApartments.Items.Add(new ListViewItem([| "107"; "2"; "1"; "Occupied";  "1275.00" |]))

apartmentRental.Controls.Add lvwApartments

do Application.Run apartmentRental

If you are not planning to use the return value of the method, end the call with the|> ignore expression. An alternative is to call the ListView.ListViewItemCollection.AddRange() method that allows you to add a collection of items in one step. Here is an example:

open System
open System.Drawing
open System.Windows.Forms 

let apartmentRental = new Form(Width = 345, Height = 178, Text = "Apartment Rental")

let lvwApartments : ListView = new ListView(Location = new Point(12, 12), Size = new Size(312, 124), GridLines = true, View = View.Details, FullRowSelect = true)

let mutable col = lvwApartments.Columns.Add("Apartment #", 75)
col <- lvwApartments.Columns.Add("Beds", 40, HorizontalAlignment.Right)
col <- lvwApartments.Columns.Add("Baths", 40, HorizontalAlignment.Right)
col <- lvwApartments.Columns.Add("Status", 75)
col <- lvwApartments.Columns.Add("Rate/month", 75, HorizontalAlignment.Right)

lvwApartments.Items.AddRange([| new ListViewItem([| "101"; "1"; "1"; "Available";  "945.00" |]);
                                new ListViewItem([| "102"; "3"; "2"; "Occupied";  "1450.00" |]);
                                new ListViewItem([| "103"; "2"; "1"; "Available"; "1275.00" |]);
                                new ListViewItem([| "104"; "1"; "1"; "Not Ready";  "945.00" |]);
                                new ListViewItem([| "105"; "2"; "2"; "Occupied";  "1325.00" |]);
                                new ListViewItem([| "106"; "3"; "1"; "Available"; "1385.00" |]);
                                new ListViewItem([| "107"; "2"; "1"; "Occupied";  "1275.00" |]) |])

apartmentRental.Controls.Add lvwApartments

do Application.Run apartmentRental
 
 
   
 

Home Copyright © 2012-2015 FunctionX Home