Prikazi cijelu temu 15.06.2018 13:20
xl_kid Van mreze
Clan
Registrovan od:11.11.2008
Lokacija:-


Predmet:Re: Kako sprečiti dupli unos u DataGrid (dupli proizvod)
Našao sam na netu ovo rešenje.

******************
Private Sub CustomDataGridView1_CellValueChanged(sender As Object, e As DataGridViewCellEventArgs) Handles CustomDataGridView1.CellValueChanged

If CustomDataGridView1.Columns(e.ColumnIndex).Name = "ProizvodIDDataGridViewTextBoxColumn" Then

'Prevent duplicates
For i As Integer = 0 To CustomDataGridView1.RowCount - 1
For j As Integer = i + 1 To CustomDataGridView1.RowCount - 2
If CustomDataGridView1.Rows(i).Cells(0).Value = CustomDataGridView1.Rows(j).Cells(0).Value Then

MsgBox("Ovaj proizvod je unet.", MsgBoxStyle.Information, "Upozorenje")

'CustomDataGridView1.CurrentCell.Value = ""

Continue For
End If

Next
Next

End If

End Sub
*****************

Prijavi mi grešku o duplom unosu što je ok. Kako sada da stovim focus na prvo polje i nastavim sa unosom. Ako stavim #CustomDataGridView1.CurrentCell.Value = ""# dozvoli mi unos ali posle entera obriše tj vrati na "". Šta sad?