ListBox.ScrollAlwaysVisible : ListBox « System.Windows.Forms « C# / C Sharp by API

Home
C# / C Sharp by API
1.Microsoft.Win32
2.System
3.System.Collections
4.System.Collections.Generic
5.System.Collections.Specialized
6.System.ComponentModel
7.System.Configuration
8.System.Data
9.System.Data.Common
10.System.Data.Linq
11.System.Data.Odbc
12.System.Data.OleDb
13.System.Data.Sql
14.System.Data.SqlClient
15.System.Diagnostics
16.System.DirectoryServices
17.System.Drawing
18.System.Drawing.Drawing2D
19.System.Drawing.Imaging
20.System.Drawing.Printing
21.System.Drawing.Text
22.System.EnterpriseServices
23.System.Globalization
24.System.IO
25.System.IO.Compression
26.System.IO.IsolatedStorage
27.System.IO.Ports
28.System.Linq
29.System.Management
30.System.Media
31.System.Messaging
32.System.Net
33.System.Net.Mail
34.System.Net.NetworkInformation
35.System.Net.Sockets
36.System.Reflection
37.System.Resources
38.System.Runtime
39.System.Runtime.CompilerServices
40.System.Runtime.InteropServices
41.System.Runtime.Remoting
42.System.Runtime.Remoting.Channels
43.System.Runtime.Remoting.Channels.Http
44.System.Runtime.Remoting.Messaging
45.System.Runtime.Serialization
46.System.Runtime.Serialization.Formatters.Binary
47.System.Runtime.Serialization.Formatters.Soap
48.System.Security
49.System.Security.AccessControl
50.System.Security.Cryptography
51.System.Security.Cryptography.X509Certificates
52.System.Security.Permissions
53.System.Security.Policy
54.System.Security.Principal
55.System.ServiceProcess
56.System.Text
57.System.Text.RegularExpressions
58.System.Threading
59.System.Timers
60.System.Web.Security
61.System.Web.Services
62.System.Windows.Controls
63.System.Windows.Forms
64.System.Xml
65.System.Xml.Linq
66.System.Xml.Schema
67.System.Xml.Serialization
68.System.Xml.XPath
69.System.Xml.Xsl
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
C# / C Sharp by API » System.Windows.Forms » ListBox 
ListBox.ScrollAlwaysVisible
 
using System;
using System.Drawing;
using System.Windows.Forms;
using System.Data;
using System.Data.SqlClient;

public class ListBoxSelectionMode : Form
{
  ListBox lb;
  RadioButton rdoMultiExtended;
  RadioButton rdoMultiSimple;
  RadioButton rdoMultiOne;
  TextBox txtTop;
  Button btnTop;

  public ListBoxSelectionMode()
  {
    int xSize, ySize;

    Size = new Size(300,400);

    lb = new ListBox();
    lb.Parent = this;
    lb.Location = new Point(10,10);
    lb.Size = new Size(ClientSize.Width - 20, Height - 200);
    lb.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Bottom;
    lb.BorderStyle = BorderStyle.Fixed3D;
    lb.MultiColumn = true;
    lb.ScrollAlwaysVisible = true;

    GroupBox grpMulti = new GroupBox();
    grpMulti.Parent = this;
    grpMulti.Text = "MultiSelect";
    grpMulti.Location = new Point(lb.Left, lb.Bottom + 25);
    grpMulti.Anchor = AnchorStyles.Left | AnchorStyles.Bottom;

    rdoMultiOne = new RadioButton();
    rdoMultiOne.Parent = grpMulti;
    rdoMultiOne.Text = "One";
    rdoMultiOne.Tag = SelectionMode.One;
    rdoMultiOne.Checked = true;
    rdoMultiOne.Location = new Point(10,15);
    rdoMultiOne.CheckedChanged += new System.EventHandler(rdoMulti_CheckedChanged);

    rdoMultiSimple = new RadioButton();
    rdoMultiSimple.Parent = grpMulti;
    rdoMultiSimple.Text = "Multi-Simple";
    rdoMultiSimple.Tag = SelectionMode.MultiSimple;
    rdoMultiSimple.Location = new Point(10, rdoMultiOne.Bottom);
    rdoMultiSimple.CheckedChanged += new System.EventHandler(rdoMulti_CheckedChanged);

    rdoMultiExtended = new RadioButton();
    rdoMultiExtended.Parent = grpMulti;
    rdoMultiExtended.Text = "Multi-Extended";
    rdoMultiExtended.Tag = SelectionMode.MultiExtended;
    rdoMultiExtended.Location = new Point(10, rdoMultiSimple.Bottom);
    rdoMultiExtended.CheckedChanged += new System.EventHandler(rdoMulti_CheckedChanged);

    xSize = (int)(Font.Height * .75* rdoMultiExtended.Text.Length;
    ySize = ((int)rdoMultiOne.Height * 320;
    grpMulti.Size = new Size(xSize, ySize);

    Panel pnlTop = new Panel();
    pnlTop.Parent = this;
    pnlTop.Location = new Point(lb.Left, grpMulti.Bottom + 10);
    pnlTop.Anchor = AnchorStyles.Left | AnchorStyles.Bottom;

    Label lblTop = new Label();
    lblTop.Parent = pnlTop;
    lblTop.Text = "TopIndex: ";
    xSize = ((int)(Font.Height * .5* lblTop.Text.Length);
    lblTop.Size = new Size(xSize, Font.Height + 10);

    txtTop = new TextBox();
    txtTop.Parent = pnlTop;
    txtTop.Location = new Point(lblTop.Right, lblTop.Top);
    txtTop.Text = lb.TopIndex.ToString();
    txtTop.Size = new Size((int)(Font.Height * .753
                Font.Height + 10);

    btnTop = new Button();
    btnTop.Parent = pnlTop;
    btnTop.Text = "Update";
    btnTop.Location = new Point(txtTop.Right + 10, txtTop.Top);
    btnTop.Click += new System.EventHandler(btnTop_Click);


    lb.Items.Add("12345");
      lb.Items.Add("67890");      
      lb.Items.Add("7890");      
      lb.Items.Add("890");            
  

  static void Main() 
  {
    Application.Run(new ListBoxSelectionMode());
  }

  private void rdoMulti_CheckedChanged(object sender, EventArgs e)
  {
    RadioButton rdo = (RadioButton)sender;
    lb.SelectionMode = (SelectionMode)rdo.Tag;
  }

  private void btnTop_Click(object sender, EventArgs e)
  {
    txtTop.Text = lb.TopIndex.ToString();
  }
}

   
  
Related examples in the same category
1.ListBox.BeginUpdate()
2.ListBox.ContextMenu
3.ListBox.DataBindings
4.ListBox.DataSource
5.ListBox.DataSourceChanged
6.ListBox.DisplayMember
7.ListBox.DisplayMemberChanged
8.ListBox.EndUpdate()
9.ListBox.FindString
10.ListBox.Items
11.ListBox.Items.Add
12.ListBox.Items.AddRange
13.ListBox.Items.Clear()
14.ListBox.Items.RemoveAt
15.ListBox.SelectedIndex
16.ListBox.SelectedIndexChanged
17.ListBox.SelectedValueChanged
18.ListBox.SelectionMode
19.ListBox.TopIndex
20.ListBox.ValueMemberChanged
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.