Form Payment 
        DGV.Columns.Add("FullName", "Customer")     '
        DGV.Columns.Add("InvNomer", "Invoice No.")       
        DGV.Columns.Add("BalanceDue", "Total")
        DGV.Columns.Add("Paid", "Paid")
       

 Private Sub cmdPayList_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdPayList.Click
        '            where = " AND InvNomer NOT IN("
        '            where = where & "'" & row(2).Value & "', "
        '            where = where & ")"
PayList.show()
 End Sub

'PayList load
        sSql = "SELECT FullName ,InvNomer, BalanceDue From Invoice"
 With LvList
            .Clear()
            .View = View.Details
            .FullRowSelect = True
            .GridLines = True
            .Columns.Add("Nama", 150)
            .Columns.Add("No.Faktur", 90)      
            .Columns.Add("Balance", 70)          
            FillListView(LvList, GetData(sSql))
        End With

    Private Sub LvList_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles LvList.KeyPress

Try
                If Not LvList.SelectedItems.Count = 0 Then
                    With LvList.SelectedItems(0)
                        Dim lvItem() As String = {.Text, .SubItems(1).Text, .SubItems(2).Text, .SubItems(3).Text} '// get ListView selectedItem.
                        DirectCast(Payment.DGV.DataSource, DataTable).Rows.Add(lvItem)
                    End With
                End If
            Catch ex As Exception
            End Try
        End If
        Me.Hide()
    End Sub

How to NoT In Paylist LvList where InvNomer have add to dgv Payment
Not Display InvNomer in LvList Paylist where InvNomer in Dgv Payment.

Anyone can help?
thanks

Recommended Answers

All 8 Replies

please format your code

my vb6 code like this

If (rsD.RecordCount > 0) Then
rsD.MoveFirst
where = " AND InvNomer NOT IN("
Do While (rsD.EOF = False)
where = where & "'" & rsD("InvNomer").Value & "', "
rsD.MoveNext
Loop
where = Left(where, Len(where) - 2)
where = where & ")"
Else
where = ""
End If
rsD.MoveLast
paylist.where = where

Sub Show()
Call ConnectAccess()
da = New OleDbDataAdapter("select Customer,InvNomer,Date,BalanceDue,PaidAmount from PaymentDetail where PaymentNomer='" & PbPaymentNo & "' ", mConn)
ds = New DataSet
da.Fill(ds, "PaymentDetail")
DGV.DataSource = ds.Tables("PaymentDetail")
DGV.Columns(0).Width = 150
DGV.Columns(1).Width = 100
DGV.Columns(2).Width = 100
DGV.Columns(3).Width = 100
DGV.Columns(4).Width = 100

cmd = New OleDbCommand("select PaymentNomer,DatePaid,Total,PaidAmount from Payment where PaymentNomer='" & PbPaymentNo & "'", mConn)
' rd = cmd.ExecuteNonQuery
rd = cmd.ExecuteReader
rd.Read()
If rd.HasRows Then
PaymentNo.Text = rd.GetValue(0)
date.Text = rd.GetValue(1)
Total.Text = rd.GetValue(2)
Paid.Text = rd.GetValue(3)

End If

End Sub

Not a database coder here, though could you not remove InvNomer, from sSql = "SELECT FullName ,InvNomer, BalanceDue From Invoice" and have it as sSql = "SELECT FullName , BalanceDue From Invoice" ?

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

Now Help me to correct my code....
First time not hide
second time very good it hide my InvNomer in my Paylist,
but third is hide not omly invnomer in dgv but all name

any one know to correct my code. thanks

hello LearnVBnet!
i read this thread more then 5 times , but i still not able to understand what is your question "How to NoT In Paylist LvList where InvNomer have add to dgv Payment
Not Display InvNomer in LvList Paylist where InvNomer in Dgv Payment." this the description of your prob ,please provide some explanation so that any one can help you in a good way ,
well as i understand that you have a list box and a grid , you want to remove all the items from the list view those are present in a grid view ,if this is your prob then try to use this code , hope this will solve your prob .

Dim i As Integer
        Dim x As Integer
        Dim find As Boolean
        Dim rec As New ArrayList
        For i = 0 To ListBox1.Items.Count - 1
            find = False
            A = ListBox1.Items(i).ToString
            For x = 0 To DataGridView1.Rows.Count - 1
                B = DataGridView1.Item(0, x).Value.ToString
                If A = B Then
                    find = True
                    Exit For
                End If
            Next
            If find = True Then
                rec.Add((ListBox1.Items(i)))
            End If
        Next
        Dim ab As Integer
        For ab = 0 To rec.Count - 1
            ListBox1.Items.Remove(rec.Item(ab))
        Next

and if this is not the answer of your prob then please rephrase your question.

Regards

Hai waqasaslammmeo

Thanks for your respon, I'm sorry my english not good
Also me think more then 5 times to make new theard,
Now I found the problem

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

thanks waqasaslammmeo and codeorder

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.