Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27512

Sorting List box But Exclude

$
0
0
OK so I have a DGV and a button that sorts the DGV based on a store Name to 2 Listviews, but what I would like to do is that if the Cell in the store name is blanks then to not add it to the sorted Listview.... Her is my current code which works well

Code:

For Each m_row As System.Windows.Forms.DataGridViewRow In Me.ShoppingListView.Rows
            If m_row.Cells("clmcmbStore").Value IsNot Nothing Then
                Dim store As String = m_row.Cells("clmcmbStore").Value.ToString
                Dim group As New ListViewGroup(store, store)
                If Not PriceMatchStore.StoreList.Groups.Cast(Of ListViewGroup).Any(Function(lvg) lvg.Name = store) Then
                    PriceMatchStore.StoreList.Groups.Add(group)
                End If

                Dim item As String = m_row.Cells("clmItem").Value.ToString
                Dim brand As String = m_row.Cells("clmBrand").Value.ToString
                Dim size As String = m_row.Cells("clmQTY").Value.ToString
                Dim price As String = m_row.Cells("clmPrice").Value.ToString
                Dim coupon As String = m_row.Cells("clmCoupon").Value.ToString

                Dim lvItem As New ListViewItem(New String() {item, brand, size, price, coupon})
                PriceMatchStore.StoreList.Items.Add(lvItem)
                PriceMatchStore.StoreList.Groups.Cast(Of ListViewGroup).First(Function(lvg) lvg.Name = store).Items.Add(lvItem)
                PriceMatchStore.StoreList.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent)
                PriceMatchStore.StoreList.AutoResizeColumn(4, ColumnHeaderAutoResizeStyle.HeaderSize)

            End If


Viewing all articles
Browse latest Browse all 27512

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>