Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

VB.NET MultiColumn CheckedListBox

Posted on 2004-09-13
8
Medium Priority
?
7,145 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 1000 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

704 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