Click here to Skip to main content
15,891,662 members
Articles / Programming Languages / Visual Basic 10

Reorderable ListView

Rate me:
Please Sign up or sign in to vote.
4.64/5 (12 votes)
14 Dec 2009CPOL9 min read 61.4K   1.6K   27  
Inherited ListView which enables user to order multiple items by mouse, and automatically scrolls if necessary
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class frmMain
  Inherits System.Windows.Forms.Form

  'Form overrides dispose to clean up the component list.
  <System.Diagnostics.DebuggerNonUserCode()> _
  Protected Overrides Sub Dispose(ByVal disposing As Boolean)
    Try
      If disposing AndAlso components IsNot Nothing Then
        components.Dispose()
      End If
    Finally
      MyBase.Dispose(disposing)
    End Try
  End Sub

  'Required by the Windows Form Designer
  Private components As System.ComponentModel.IContainer

  'NOTE: The following procedure is required by the Windows Form Designer
  'It can be modified using the Windows Form Designer.  
  'Do not modify it using the code editor.
  <System.Diagnostics.DebuggerStepThrough()> _
  Private Sub InitializeComponent()
    Me.nudMaxScrollAreaSize = New System.Windows.Forms.NumericUpDown
    Me.Label1 = New System.Windows.Forms.Label
    Me.nudIlWidth = New System.Windows.Forms.NumericUpDown
    Me.Label2 = New System.Windows.Forms.Label
    Me.btnSelectILColor = New System.Windows.Forms.Button
    Me.ShowReorderedEvt = New System.Windows.Forms.CheckBox
    Me.btnReset = New System.Windows.Forms.Button
    Me.coldDlg = New System.Windows.Forms.ColorDialog
    Me.ListView1 = New System.Windows.Forms.ListView
    Me.ColumnHeader2 = New System.Windows.Forms.ColumnHeader
    Me.TableLayoutPanel1 = New System.Windows.Forms.TableLayoutPanel
    Me.TableLayoutPanel2 = New System.Windows.Forms.TableLayoutPanel
    Me.lvrMain = New Support.cControls.ListViewRO
    Me.ColumnHeader1 = New System.Windows.Forms.ColumnHeader
    Me.PropertyGrid1 = New System.Windows.Forms.PropertyGrid
    CType(Me.nudMaxScrollAreaSize, System.ComponentModel.ISupportInitialize).BeginInit()
    CType(Me.nudIlWidth, System.ComponentModel.ISupportInitialize).BeginInit()
    Me.TableLayoutPanel1.SuspendLayout()
    Me.TableLayoutPanel2.SuspendLayout()
    Me.SuspendLayout()
    '
    'nudMaxScrollAreaSize
    '
    Me.nudMaxScrollAreaSize.Location = New System.Drawing.Point(3, 16)
    Me.nudMaxScrollAreaSize.Name = "nudMaxScrollAreaSize"
    Me.nudMaxScrollAreaSize.Size = New System.Drawing.Size(92, 20)
    Me.nudMaxScrollAreaSize.TabIndex = 1
    '
    'Label1
    '
    Me.Label1.AutoSize = True
    Me.Label1.Location = New System.Drawing.Point(3, 0)
    Me.Label1.Name = "Label1"
    Me.Label1.Size = New System.Drawing.Size(95, 13)
    Me.Label1.TabIndex = 2
    Me.Label1.Text = "MaxScrollAreaSize"
    '
    'nudIlWidth
    '
    Me.nudIlWidth.Location = New System.Drawing.Point(3, 55)
    Me.nudIlWidth.Margin = New System.Windows.Forms.Padding(3, 3, 3, 20)
    Me.nudIlWidth.Name = "nudIlWidth"
    Me.nudIlWidth.Size = New System.Drawing.Size(92, 20)
    Me.nudIlWidth.TabIndex = 1
    '
    'Label2
    '
    Me.Label2.AutoSize = True
    Me.Label2.Location = New System.Drawing.Point(3, 39)
    Me.Label2.Name = "Label2"
    Me.Label2.Size = New System.Drawing.Size(94, 13)
    Me.Label2.TabIndex = 2
    Me.Label2.Text = "Insertion line width"
    '
    'btnSelectILColor
    '
    Me.btnSelectILColor.ForeColor = System.Drawing.SystemColors.Window
    Me.btnSelectILColor.Location = New System.Drawing.Point(3, 98)
    Me.btnSelectILColor.Margin = New System.Windows.Forms.Padding(3, 3, 3, 20)
    Me.btnSelectILColor.Name = "btnSelectILColor"
    Me.btnSelectILColor.Size = New System.Drawing.Size(99, 23)
    Me.btnSelectILColor.TabIndex = 3
    Me.btnSelectILColor.Text = "InsertionLineColor"
    Me.btnSelectILColor.UseVisualStyleBackColor = True
    '
    'ShowReorderedEvt
    '
    Me.ShowReorderedEvt.AllowDrop = True
    Me.ShowReorderedEvt.AutoSize = True
    Me.ShowReorderedEvt.Location = New System.Drawing.Point(3, 144)
    Me.ShowReorderedEvt.Name = "ShowReorderedEvt"
    Me.ShowReorderedEvt.Size = New System.Drawing.Size(101, 30)
    Me.ShowReorderedEvt.TabIndex = 4
    Me.ShowReorderedEvt.Text = "Show results of " & Global.Microsoft.VisualBasic.ChrW(13) & Global.Microsoft.VisualBasic.ChrW(10) & "reordered event"
    Me.ShowReorderedEvt.UseVisualStyleBackColor = True
    '
    'btnReset
    '
    Me.btnReset.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
    Me.btnReset.Location = New System.Drawing.Point(8, 242)
    Me.btnReset.Name = "btnReset"
    Me.btnReset.Size = New System.Drawing.Size(99, 23)
    Me.btnReset.TabIndex = 3
    Me.btnReset.Text = "RESET"
    Me.btnReset.UseVisualStyleBackColor = True
    '
    'coldDlg
    '
    Me.coldDlg.AnyColor = True
    Me.coldDlg.Color = System.Drawing.Color.Blue
    Me.coldDlg.FullOpen = True
    '
    'ListView1
    '
    Me.ListView1.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
                Or System.Windows.Forms.AnchorStyles.Left) _
                Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
    Me.ListView1.BackColor = System.Drawing.SystemColors.ControlDarkDark
    Me.ListView1.Columns.AddRange(New System.Windows.Forms.ColumnHeader() {Me.ColumnHeader2})
    Me.ListView1.ForeColor = System.Drawing.SystemColors.Window
    Me.ListView1.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable
    Me.ListView1.Location = New System.Drawing.Point(3, 3)
    Me.ListView1.Name = "ListView1"
    Me.ListView1.Size = New System.Drawing.Size(116, 268)
    Me.ListView1.TabIndex = 5
    Me.ListView1.UseCompatibleStateImageBehavior = False
    Me.ListView1.View = System.Windows.Forms.View.Details
    '
    'ColumnHeader2
    '
    Me.ColumnHeader2.Text = "Drag from here"
    Me.ColumnHeader2.Width = 91
    '
    'TableLayoutPanel1
    '
    Me.TableLayoutPanel1.ColumnCount = 4
    Me.TableLayoutPanel1.ColumnStyles.Add(New System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 122.0!))
    Me.TableLayoutPanel1.ColumnStyles.Add(New System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 122.0!))
    Me.TableLayoutPanel1.ColumnStyles.Add(New System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 116.0!))
    Me.TableLayoutPanel1.ColumnStyles.Add(New System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100.0!))
    Me.TableLayoutPanel1.Controls.Add(Me.TableLayoutPanel2, 2, 0)
    Me.TableLayoutPanel1.Controls.Add(Me.ListView1, 0, 0)
    Me.TableLayoutPanel1.Controls.Add(Me.lvrMain, 1, 0)
    Me.TableLayoutPanel1.Controls.Add(Me.PropertyGrid1, 3, 0)
    Me.TableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill
    Me.TableLayoutPanel1.Location = New System.Drawing.Point(0, 0)
    Me.TableLayoutPanel1.Name = "TableLayoutPanel1"
    Me.TableLayoutPanel1.RowCount = 1
    Me.TableLayoutPanel1.RowStyles.Add(New System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100.0!))
    Me.TableLayoutPanel1.Size = New System.Drawing.Size(589, 274)
    Me.TableLayoutPanel1.TabIndex = 7
    '
    'TableLayoutPanel2
    '
    Me.TableLayoutPanel2.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
                Or System.Windows.Forms.AnchorStyles.Left) _
                Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
    Me.TableLayoutPanel2.ColumnCount = 1
    Me.TableLayoutPanel2.ColumnStyles.Add(New System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100.0!))
    Me.TableLayoutPanel2.Controls.Add(Me.Label1, 0, 0)
    Me.TableLayoutPanel2.Controls.Add(Me.nudMaxScrollAreaSize, 0, 1)
    Me.TableLayoutPanel2.Controls.Add(Me.btnReset, 0, 6)
    Me.TableLayoutPanel2.Controls.Add(Me.ShowReorderedEvt, 0, 5)
    Me.TableLayoutPanel2.Controls.Add(Me.Label2, 0, 2)
    Me.TableLayoutPanel2.Controls.Add(Me.nudIlWidth, 0, 3)
    Me.TableLayoutPanel2.Controls.Add(Me.btnSelectILColor, 0, 4)
    Me.TableLayoutPanel2.Location = New System.Drawing.Point(247, 3)
    Me.TableLayoutPanel2.Name = "TableLayoutPanel2"
    Me.TableLayoutPanel2.RowCount = 7
    Me.TableLayoutPanel2.RowStyles.Add(New System.Windows.Forms.RowStyle)
    Me.TableLayoutPanel2.RowStyles.Add(New System.Windows.Forms.RowStyle)
    Me.TableLayoutPanel2.RowStyles.Add(New System.Windows.Forms.RowStyle)
    Me.TableLayoutPanel2.RowStyles.Add(New System.Windows.Forms.RowStyle)
    Me.TableLayoutPanel2.RowStyles.Add(New System.Windows.Forms.RowStyle)
    Me.TableLayoutPanel2.RowStyles.Add(New System.Windows.Forms.RowStyle)
    Me.TableLayoutPanel2.RowStyles.Add(New System.Windows.Forms.RowStyle)
    Me.TableLayoutPanel2.Size = New System.Drawing.Size(110, 268)
    Me.TableLayoutPanel2.TabIndex = 8
    '
    'lvrMain
    '
    Me.lvrMain.AllowDrop = True
    Me.lvrMain.AllowReorder = False
    Me.lvrMain.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
                Or System.Windows.Forms.AnchorStyles.Left) _
                Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
    Me.lvrMain.Columns.AddRange(New System.Windows.Forms.ColumnHeader() {Me.ColumnHeader1})
    Me.lvrMain.DragMouseButton = System.Windows.Forms.MouseButtons.Left
    Me.lvrMain.FullRowSelect = True
    Me.lvrMain.GridLines = True
    Me.lvrMain.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable
    Me.lvrMain.InsertionLineColor = System.Drawing.Color.FromArgb(CType(CType(0, Byte), Integer), CType(CType(0, Byte), Integer), CType(CType(255, Byte), Integer))
    Me.lvrMain.InsertionLineWidth = 2.0!
    Me.lvrMain.Location = New System.Drawing.Point(125, 3)
    Me.lvrMain.MaxScrollAreaSize = 3
    Me.lvrMain.Name = "lvrMain"
    Me.lvrMain.Size = New System.Drawing.Size(116, 268)
    Me.lvrMain.TabIndex = 0
    Me.lvrMain.UseCompatibleStateImageBehavior = False
    Me.lvrMain.View = System.Windows.Forms.View.Details
    '
    'ColumnHeader1
    '
    Me.ColumnHeader1.Text = "Reorder & insert"
    Me.ColumnHeader1.Width = 88
    '
    'PropertyGrid1
    '
    Me.PropertyGrid1.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
                Or System.Windows.Forms.AnchorStyles.Left) _
                Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
    Me.PropertyGrid1.Location = New System.Drawing.Point(363, 3)
    Me.PropertyGrid1.Name = "PropertyGrid1"
    Me.PropertyGrid1.SelectedObject = Me.lvrMain
    Me.PropertyGrid1.Size = New System.Drawing.Size(223, 268)
    Me.PropertyGrid1.TabIndex = 9
    '
    'frmMain
    '
    Me.AllowDrop = True
    Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
    Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
    Me.ClientSize = New System.Drawing.Size(589, 274)
    Me.Controls.Add(Me.TableLayoutPanel1)
    Me.Name = "frmMain"
    Me.ShowIcon = False
    Me.Text = "ListViewRO test"
    CType(Me.nudMaxScrollAreaSize, System.ComponentModel.ISupportInitialize).EndInit()
    CType(Me.nudIlWidth, System.ComponentModel.ISupportInitialize).EndInit()
    Me.TableLayoutPanel1.ResumeLayout(False)
    Me.TableLayoutPanel2.ResumeLayout(False)
    Me.TableLayoutPanel2.PerformLayout()
    Me.ResumeLayout(False)

  End Sub
  Friend WithEvents lvrMain As Support.cControls.ListViewRO
  Friend WithEvents nudMaxScrollAreaSize As System.Windows.Forms.NumericUpDown
  Friend WithEvents Label1 As System.Windows.Forms.Label
  Friend WithEvents nudIlWidth As System.Windows.Forms.NumericUpDown
  Friend WithEvents Label2 As System.Windows.Forms.Label
  Friend WithEvents btnSelectILColor As System.Windows.Forms.Button
  Friend WithEvents ShowReorderedEvt As System.Windows.Forms.CheckBox
  Friend WithEvents ColumnHeader1 As System.Windows.Forms.ColumnHeader
  Friend WithEvents btnReset As System.Windows.Forms.Button
  Friend WithEvents coldDlg As System.Windows.Forms.ColorDialog
  Friend WithEvents ListView1 As System.Windows.Forms.ListView
  Friend WithEvents ColumnHeader2 As System.Windows.Forms.ColumnHeader
  Friend WithEvents TableLayoutPanel1 As System.Windows.Forms.TableLayoutPanel
  Friend WithEvents TableLayoutPanel2 As System.Windows.Forms.TableLayoutPanel
  Friend WithEvents PropertyGrid1 As System.Windows.Forms.PropertyGrid



End Class

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer piSoft
Czech Republic Czech Republic
Developing is my hobby and preferred job. Currently looking for good, creative and innovative job.

Comments and Discussions