Solved

VB.NET MultiColumn CheckedListBox

Posted on 2004-09-13
8
7,087 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 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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 

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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Suggested Courses

636 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