Solved

VB.NET MultiColumn CheckedListBox

Posted on 2004-09-13
8
6,979 Views
Last Modified: 2012-08-14
Hi all. As I'm upgrading to vb.NET, I need help making a MultiColumn CheckedListBox, first column would have squares containing colors (or just the background color of the item) so by clicking them I call the colorBox to change the color; the second column would have RichTextBox (so every item can display symbols, colors...).
I assume I need to make a user-control and when the checkedListBox is changed; I would need to make a new richTextBox in the second column of that item...
I appreciate any help.

I know how to access a row, how can I access a column ?
Is there any way I can have two columns with different widths ?
0
Comment
Question by:Dan-Key
  • 4
  • 4
8 Comments
 
LVL 10

Expert Comment

by:prakash_prk
ID: 12051241
Try the windows forms listview control

0
 

Author Comment

by:Dan-Key
ID: 12066939
This is not the expected result.
        ListView1.Columns.Add("color1", 20, HorizontalAlignment.Left)
        ListView1.Items.Add("Text" & ListView1.Items.Count & " is here")
It does not appear with a checkBox ! and I can not set BackColor a specific item in the first column...It automatically puts columns at the next row, or puts new rows at the new column but asme row !
I still think maybe a checkedListBox would work.
Please comment with some details. Thanks.
0
 
LVL 10

Accepted Solution

by:
prakash_prk earned 250 total points
ID: 12071906
Hi Dan-key
                I doesn't know your exact requierment so that i only said "try the listview control" sorry for that.
Try this code
------------------
Public Class Form1
    Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    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.
    Friend WithEvents ListView1 As System.Windows.Forms.ListView
    Friend WithEvents Color As System.Windows.Forms.ColumnHeader
    Friend WithEvents SomeText As System.Windows.Forms.ColumnHeader
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Dim ListViewItem1 As System.Windows.Forms.ListViewItem = New System.Windows.Forms.ListViewItem(New String() {"", "There is a text"}, -1, System.Drawing.Color.Empty, System.Drawing.Color.Brown, Nothing)
        Dim ListViewItem2 As System.Windows.Forms.ListViewItem = New System.Windows.Forms.ListViewItem(New String() {"", "hai"}, -1, System.Drawing.Color.Empty, System.Drawing.Color.Orange, Nothing)
        Me.ListView1 = New System.Windows.Forms.ListView
        Me.Color = New System.Windows.Forms.ColumnHeader
        Me.SomeText = New System.Windows.Forms.ColumnHeader
        Me.SuspendLayout()
        '
        'ListView1
        '
        Me.ListView1.CheckBoxes = True
        Me.ListView1.Columns.AddRange(New System.Windows.Forms.ColumnHeader() {Me.Color, Me.SomeText})
        Me.ListView1.FullRowSelect = True
        ListViewItem1.StateImageIndex = 0
        ListViewItem1.UseItemStyleForSubItems = False
        ListViewItem2.StateImageIndex = 0
        ListViewItem2.UseItemStyleForSubItems = False
        Me.ListView1.Items.AddRange(New System.Windows.Forms.ListViewItem() {ListViewItem1, ListViewItem2})
        Me.ListView1.Location = New System.Drawing.Point(72, 104)
        Me.ListView1.Name = "ListView1"
        Me.ListView1.Size = New System.Drawing.Size(176, 97)
        Me.ListView1.TabIndex = 0
        Me.ListView1.View = System.Windows.Forms.View.Details
        '
        'Color
        '
        Me.Color.Text = "Color"
        Me.Color.Width = 75
        '
        'SomeText
        '
        Me.SomeText.Text = "Text"
        Me.SomeText.Width = 86
        '
        'Form1
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(292, 273)
        Me.Controls.Add(Me.ListView1)
        Me.Name = "Form1"
        Me.Text = "Form1"
        Me.ResumeLayout(False)

    End Sub

#End Region

    Private Sub ListView1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListView1.SelectedIndexChanged

    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub
End Class
--------------------
Check this link
http://www.c-sharpcorner.com//Code/2002/July/EditableListView.asp


regards
prakash
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:Dan-Key
ID: 12086434
Hi prakash. You sample is very very close to what I want.
Would you please let me know, how to do the following:
To add an item this does not work:
        ListView1.Items.Add("")
        ListView1.Items(ListView1.Items.Count - 1).SubItems(0).BackColor = System.Drawing.Color.Red
        ListView1.Items(ListView1.Items.Count - 1).SubItems(1).Text = "new item"


Also, if anyone knows how to put an image in a third item, that would be great.
Thanks a lot.
Regards, Dan-Key
0
 

Author Comment

by:Dan-Key
ID: 12090374
Hi. The following works:
        ListView1.Items(ListView1.Items.Count - 1).SubItems.Add("New item", Drawing.Color.Black, Drawing.Color.White, ListView1.Font)

About having a picture in an item, I'll try. Any futher help would be appreciated.
0
 
LVL 10

Expert Comment

by:prakash_prk
ID: 12090413
Add a imagelist control
Add images to it .

Then set the LargeImageList to imagelist you added

Add items set the state image index

regards
prakash
0
 

Author Comment

by:Dan-Key
ID: 12094145
Prakash, Thanks to you. ListView is useful...
Have a great time.
0
 
LVL 10

Expert Comment

by:prakash_prk
ID: 12099284
Thank you Dan-Key

regards
prakash
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

791 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question