none
How To Hide Listview Rows vbnet RRS feed

  • Question

  • ' PayList form

    sSql = "SELECT FullName ,InvNomer, date,BalanceDue FROM Invoice" With LvList .Columns.Add("Name", 150) .Columns.Add("InvNomer", 90) .Columns.Add("Date", 90) .Columns.Add("Balance", 70) FillListView(LvList, GetData(sSql))

    After I ADD To my Payment Datagridview

    Payment Form

    With InvNomer in DGV.Rows(i).Cells(1).Value

            DGV.Columns.Add("FullName", "Name")
            DGV.Columns.Add("InvNomer", "InvNomer")
            DGV.Columns.Add("Date", "Date")
            DGV.Columns.Add("BalanceDue", "Total")
          

    Now Help me to hide my Paylist row with InvNomer  where InvNomer in Payment.DGV.rows(i).cell(1).value

    I Have tried

    Private Sub cmdPaylist_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdPaylist.Click
            If pbNew Then
                Dim AllItems As String = ""
                For i As Integer = 0 To DGV.Rows.Count - 1
                    For Itm = 0 To PayList.LvList1.Items.Count - 1
                        AllItems = AllItems & PayList.LvList1.Items.Item(Itm).Text & vbNewLine
                        AllItems = AllItems.Trim
                        With PayList.LvList1
                            Dim lvItem1 As String = DGV.Rows(i).Cells(1).Value
                            If Val(.Items(Itm).SubItems(1).Text) = lvItem1 Then
                            .Items(Itm).Remove()
                            End If
                        End With
                    Next
                Next
                PayList.Show()
                PayList.pbNew = True
            End If
        End Sub

    But cannot work

    Can anyone know how to hide Listview rows

    Please Help

    LearnVbnet

    Friday, February 17, 2012 5:54 AM

Answers

  • try to do this never or you should handle a known bug in .Net.

    Try If Val(.Items(Itm).SubItems(1).Text) = lvItem1 Then PayList.LvList.Items.RemoveAt(Itm) End If Catch ex As Exception

    brrrrrrrrrrrrrrrrrr marks a very bad programmer

    End Try

    If you need this and it is not to go around a known bug in .Net than there is probably something wrong in your code.

    If you want to create a distinct listview, than use a datatable to populate the datagridview and you can use the Defaultview of that which is set to distinct. 

    But something like that I wrote already in my first message in this thread. 

    By the way, what do you mean with your nick. It seems you don't want to learn but to proof that everything should be done in your way which is proven wrong?


    Success
    Cor

    • Marked as answer by LearnVBnet Friday, February 17, 2012 10:44 AM
    Friday, February 17, 2012 9:14 AM

All replies

  • Hello Learn VB Net

    Strange code, try to learn that a control is to show data not to manipulate data. So moving data from one multi line control to another multi line one is mostly strange. 

    Also try to learn that there are 3 kind of grids, DataGrids (which are in Windows Forms the DataGrid and the DataGridView), Spreadsheets and Lists. 

    A List hold items which can have subitems (in the case of the listview)
    A DataGrid holds rows which contain items 
    A SpreadSheet holds cells which have in fact not really a relation to a row.

    So if you are looking to Items and subitems, you have to look at the item and how to hide that.

    Like you can see here has the listview item no hide or visibility property, so you have to remove it temporaly.

    http://msdn.microsoft.com/en-us/library/system.windows.forms.listviewitem_properties.aspx  

    Be aware that the Listview is simply the control which you see as right pane in My Computer or Windows Explorer and has the same features in its view property of the listviewitemcollection


    Success
    Cor


    Friday, February 17, 2012 6:04 AM
  • Hi

    I have an other idiea.. try this may be it will helps to you..

    ListView1.ListItems(2).width = 0 


    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful"

    Friday, February 17, 2012 6:08 AM
  • I want to hide all row not sub item

    all row lvlist where InvNomer in lvlist.subItem(1) like in

     DGV.Rows(i).Cells(1).Value

    ex. If my lvlist have InvNomer 1 to 5

    then add to dgv no.1

    after I click my paylist again

    then I want my lvlist hide no.1

    that mean in my lvlist row, now only no.2,3,4,5

    Friday, February 17, 2012 6:20 AM
  •  Private Sub cmdPaylist_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdPaylist.Click
            If pbNew Then
                Dim AllItems As String = ""
                For i As Integer = 0 To DGV.Rows.Count - 1
                    For Itm = 0 To PayList.LvList.Items.Count - 1
                        With PayList.LvList
                            Dim lvItem1 As String = DGV.Rows(i).Cells(1).Value
                            Try
                                If Val(.Items(Itm).SubItems(1).Text) = lvItem1 Then
                                    PayList.LvList.Items.RemoveAt(Itm)
                                End If
                            Catch ex As Exception
                            End Try
                        End With
                    Next
                Next
                PayList.Show()
                PayList.pbNew = True
            End If
        End Sub

    Now This like almost true

    Please help me to corect my code.

    In first time not hide, second time hide the row and good, but third not stabil again.... hide to much

    Friday, February 17, 2012 6:48 AM
  • LearnVb, I just wanted to compliment you. Yours is a competent thread!

    Renee


    "MODERN PROGRAMMING is deficient in elementary ways BECAUSE of problems INTRODUCED by MODERN PROGRAMMING." Me

    Friday, February 17, 2012 8:37 AM
  • try to do this never or you should handle a known bug in .Net.

    Try If Val(.Items(Itm).SubItems(1).Text) = lvItem1 Then PayList.LvList.Items.RemoveAt(Itm) End If Catch ex As Exception

    brrrrrrrrrrrrrrrrrr marks a very bad programmer

    End Try

    If you need this and it is not to go around a known bug in .Net than there is probably something wrong in your code.

    If you want to create a distinct listview, than use a datatable to populate the datagridview and you can use the Defaultview of that which is set to distinct. 

    But something like that I wrote already in my first message in this thread. 

    By the way, what do you mean with your nick. It seems you don't want to learn but to proof that everything should be done in your way which is proven wrong?


    Success
    Cor

    • Marked as answer by LearnVBnet Friday, February 17, 2012 10:44 AM
    Friday, February 17, 2012 9:14 AM
  • I dont know what to say and write here...

    I' m sorry my english not good.

    I'm very thanks to Renee Culver and Cor Ligthert for respon my thread

    I dont understand , this is very dificult to me, but after I asked to forum, I can found the answer

    Now this thread is solved when I kick "Val"

    Try

     '  If Val(.Items(Itm).SubItems(1).Text) = lvItem1 Then

    If .Items(Itm).SubItems(1).Text = lvItem1 Then PayList.LvList.Items.RemoveAt(Itm) End If Catch ex As Exception 'Thanks To Renee Culver and Cor Ligthert End Try

    Thanks All

    Regards Learnvbnet

    Friday, February 17, 2012 10:43 AM
  • brrrrrrrrrrrrrrrrrr marks a very bad programmer
    Really? Is this just plain arrogance or lack of social behavior or both? You could have at least prefixed it by a remark considering your score. I know this thread is of age but as you know or not, Internet keeps hitting back in the face any time, any place. Cheerio Dutchy.
    Monday, June 29, 2020 6:24 AM