C#
  Home arrow C# arrow Page 6 - C# Simplified, part 7: Working with WinFor...
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 
Mobile Linux 
App Generation ROI 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
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? 
C#

C# Simplified, part 7: Working with WinForm Controls
By: Anand Narayanaswamy
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 11
    2005-06-14

    Table of Contents:
  • C# Simplified, part 7: Working with WinForm Controls
  • Working with Checkboxes
  • Working with RadioButtons
  • Working with Labels
  • Working with Combo boxes
  • Working with List boxes

  • 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


    C# Simplified, part 7: Working with WinForm Controls - Working with List boxes


    (Page 6 of 6 )

    The process of creating a list box is the same as for a combo box. The only difference is that you can select more than one item using a list box. By default, though, you can select only one item. In order to select multiple items you have to set the SelectionMode property of the list box to MultiSimple or MultiExtended.

    The MultiSimple property enables you to select all items with mouse clicks. It toggles the selected item. On the other hand, the MultiExtended property enables you to select items by holding either the Shift or Control key. The code for producing a list box using the MultiSimple property is shown in listing 7.7

    Listing 7.7

    001: using System;
    002: using System.Drawing;
    003: using System.Windows.Forms;
    004:
    005: public class MyListbox: Form
    006: {
    007:   // Object of Label created
    008:   ListBox lb = new ListBox();
    009:
    010:   MyListbox()
    011:   {
    012:     this.Controls.Add(lb);
    013:     lb.Items.Add("Visual Basic .NET");
    014:     lb.Items.Add("Visual C# .NET");
    015:     lb.Items.Add("Visual J# .NET");
    016:     lb.Text = "Please select";
    017:     lb.SelectionMode = SelectionMode.MultiSimple;
    018:     lb.Location = new Point(50,50);
    019:     lb.Size = new Size(200,70);
    020:     this.Text = "C# FAQ - List box Control";
    021:   }
    022:
    023:   public static void Main()
    024:   {
    025:     Application.Run(new MyListbox());
    026:   }
    027: }

    Output

    In the next article, you will learn how to handle events using the above explained controls.


    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.

     

    C# ARTICLES

    - C# and XML
    - Pointers and Arrays in C#
    - C# 3.0 Extension Methods
    - Overloading Operators in C#
    - Iterators and Nullable Types
    - Patterns and Iterators in C#
    - C# Exceptions
    - Methods in C#
    - Delegates and Events in C#
    - Advanced C#
    - Working with Regular Expressions in C#
    - Sending Simple E-Mail in C#
    - Building C# Comparable Objects: IComparable ...
    - Color Transformation Applications in C# GDI+...
    - Performing Color Transformation Operations i...





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
    Stay green...Green IT