Hi,
when I used a comboBox to search for a customer. The customer data will display in a grid. BUT i always get the wrong data from what i selected from the grid. How can i solved this problem?
On form2
Private Sub btnSearchName_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSearchName.Click
With Me.dvCustomer.Table
With DataGrid1
.CaptionText = "Search by Last Name"
End With
If cboLastName.Text = "
" Then
.DefaultView.RowFilter = "CustLName like '%'"
Else
.DefaultView.RowFilter = "CustLName like '" & cboLastName.Text & "%'"
End If
If BindingContext(Me.DataSet11.Customers).Position < 0 Then
With DataGrid1
.CaptionText = "Database is empty !"
End With
End If
dt = .DefaultView.Table
End With
Me.DataGrid1.DataSource = dt
End Sub
Private Sub DataGrid1_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles DataGrid1.DoubleClick
s.id = dt.Rows(DataGrid1.CurrentCell.RowNumber)(0)
s.Lname = dt.Rows(DataGrid1.CurrentCell.RowNumber)(1)
s.Fname = dt.Rows(DataGrid1.CurrentCell.RowNumber)(2)
s.title = dt.Rows(DataGrid1.CurrentCell.RowNumber)(3)
s.ic = dt.Rows(DataGrid1.CurrentCell.RowNumber)(4)
s.DoB = dt.Rows(DataGrid1.CurrentCell.RowNumber)(5)
s.deposit = dt.Rows(DataGrid1.CurrentCell.RowNumber)(6)
s.g = dt.Rows(DataGrid1.CurrentCell.RowNumber)(7)
s.jd = dt.Rows(DataGrid1.CurrentCell.RowNumber)(8)
s.add_1 = dt.Rows(DataGrid1.CurrentCell.RowNumber)(9)
s.add_2 = dt.Rows(DataGrid1.CurrentCell.RowNumber)(10)
s.postcode = dt.Rows(DataGrid1.CurrentCell.RowNumber)(11)
s.city = dt.Rows(DataGrid1.CurrentCell.RowNumber)(12)
s.state = dt.Rows(DataGrid1.CurrentCell.RowNumber)(13)
s.hp = dt.Rows(DataGrid1.CurrentCell.RowNumber)(14)
s.wp = dt.Rows(DataGrid1.CurrentCell.RowNumber)(15)
s.cp = dt.Rows(DataGrid1.CurrentCell.RowNumber)(16)
s.email = dt.Rows(DataGrid1.CurrentCell.RowNumber)(17)
Close()
End Sub
On form1
Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSearch.Click
Dim f As New frmCustSearch
f.ShowDialog()
Dim s As frmCustSearch.Customers = f.selecteditems
If Not IsNothing(s) Then
txtCustomerNo.Text = s.id
txtFirstName.Text = s.Fname
txtLastName.Text = s.Lname
cboTitle.Text = s.title
txtICNo.Text = s.ic
txtDoB.Text = s.DoB
txtDeposit.Text = s.deposit
If s.g = "M" Then
rbM.Checked = True
ElseIf s.g = "F" Then
rbF.Checked = True
End If
txtJoinDate.Text = s.jd
txtAddress_1.Text = s.add_1
txtAddress_2.Text = s.add_2
txtPostcode.Text = s.postcode
txtCity.Text = s.city
txtState.Text = s.state
txtHPhone.Text = s.hp
txtWPhone.Text = s.wp
txtCPhone.Text = s.cp
txtEmail.Text = s.email
End If
End Sub
Any help or examples is appreciated
viv