Welcome Guest Search | Active Topics | Members | Log In | Register

Button/Command column? Options
yaplej
Posted: Sunday, May 02, 2010 12:18:13 AM
Rank: Member

Joined: 7/6/2009
Posts: 20
Points: -40
Location: Oregon
Is it possible to add a subitem that is a button? Iv figured out how to add subitems into the list, but am not sure how to make one of them a button.

What I am trying to do it make a "Delete" button for each row in the listview so the user can click this delete button, and be prompted to confirm yes/no if they want to delete the record. Upon choosing yes the record would be deleted, and the listview would refresh.

Code:

        Dim item As LidorSystems.IntegralUI.Lists.ListViewItem = Nothing
        Dim subItem As LidorSystems.IntegralUI.Lists.ListViewSubItem = Nothing

        For Each dr As DataRow In dtTimeCards
            item = New LidorSystems.IntegralUI.Lists.ListViewItem

            For j As Integer = 0 To ListView1.Columns.Count - 1
                subItem = New LidorSystems.IntegralUI.Lists.ListViewSubItem(("Item " & dr.Item("TimeCardID").ToString) + j.ToString())
                subItem.Value = subItem.Text

                item.SubItems.Add(subItem)

            Next

            ListView1.Items.Add(item)

        Next

LidorSystems Support
Posted: Sunday, May 02, 2010 9:06:15 AM

Rank: Administration

Joined: 6/10/2005
Posts: 637
Points: 1,365
You can do this in two ways:

1. Show only a Button in each subitem for specified column.

At first set the type specified column to contain controls:

Code:
Me.listView1.Columns(1).ContentType = ColumnContentType.Control
Me.listView1.Columns(1).ContentControlVisibility = ContentControlVisibility.AlwaysVisible


Then add a Button control to each subitem in this column:

Code:
Dim btn As Button = Nothing
For Each item As LidorSystems.IntegralUI.Lists.ListViewItem In Me.listView1.Items
    For j As Integer = 0 To Me.listView1.Columns.Count - 1
        Dim subItem As LidorSystems.IntegralUI.Lists.ListViewSubItem = New ListViewSubItem()
        subItem.Text = ("Item " & item.Index) + j.ToString()
       
        Select Case Me.listView1.Columns(j).ContentType
            Case ColumnContentType.Control
                btn = New Button()
                btn.Size = New Size(60, 22)
                btn.Text = subItem.Text
                AddHandler btn.Click, AddressOf btn_Click
                subItem.Control = btn
                Exit Select
         End Select
       
        item.SubItems.Add(subItem)
    Next
Next

Me.listView1.UpdateLayout()


2. Show a custom rich content in some subitem for specified column.

At first set the type specified column to contain custom content:

Code:
Me.listView1.Columns(2).ContentType = ColumnContentType.Custom


Then create a custom content to some subitem in this column:

Code:

Dim btn As Button = Nothing
For Each item As LidorSystems.IntegralUI.Lists.ListViewItem In Me.listView1.Items
    For j As Integer = 0 To Me.listView1.Columns.Count - 1
        Dim subItem As LidorSystems.IntegralUI.Lists.ListViewSubItem = New ListViewSubItem()
        subItem.Text = ("Item " & item.Index) + j.ToString()
       
        Select Case Me.listView1.Columns(j).ContentType
            Case ColumnContentType.[Custom]
                btn = New Button()
                btn.Size = New Size(60, 22)
                btn.Text = subItem.Text
                AddHandler btn.Click, AddressOf btn_Click
                subItem.Controls.Add(btn)
               
                subItem.Content = "<div>" & subItem.Text & " <control index=""0""></control></div>"
                Exit Select
        End Select
       
        item.SubItems.Add(subItem)
    Next
Next

Me.listView1.UpdateLayout()


yaplej
Posted: Wednesday, May 05, 2010 6:33:35 AM
Rank: Member

Joined: 7/6/2009
Posts: 20
Points: -40
Location: Oregon
That worked to add the button, but its only visible when you enter that row/column. Is there any way for it to be visible for all the rows without having to first click into the row/column?
yaplej
Posted: Wednesday, May 05, 2010 6:35:28 AM
Rank: Member

Joined: 7/6/2009
Posts: 20
Points: -40
Location: Oregon
Nevermind. Playing around with the column settings I found the control alwaysvisible setting.
Users browsing this topic
Guest


Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Main Forum RSS : RSS

Powered by Yet Another Forum.net version 1.9.0 (NET v2.0) - 10/10/2006
Copyright © 2003-2006 Yet Another Forum.net. All rights reserved.
This page was generated in 0.076 seconds.