G
Gary Simpson
Guest
Hi Good People
On my form I have a DataGridView that I have dragged onto the form via the Data source column, I have also dragged Labels onto the form not all, Only the data I wish to see.
When I click on a row in the DataGridView the Labels work well they show all the data I require.
I also put a textbox on the form to search a particular Column in the DataGridView. this works fine, it narrows down what I am looking/Searching for in the DataGridView.
But here come my issue...
Once I have used the textbox, And I click on the DataGridView row, the Labels are no Longer Updated.
Can someone please help with this Issue
The code from my textbox is...
Private Sub FetchName(Name As String)
SQL.AddParam("@Cust", "%" & Name & "%")
SQL.ExecQuery("Select * FROM JobsCompleted " &
"WHERE Name LIKE @Cust")
dgvJobsCompleted.DataSource = SQL.SQLDT
End Sub
Private Sub txtFilterName_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtFilterName.KeyPress
FetchName(txtFilterName.Text)
End Sub
I have also tried get values from the DataGridView into the Labels with this code. But I still get the same Issue
Private Sub GetName()
SQL.ExecQuery("SELECT * FROM JobsComplete ")
If SQL.RecordCount < 1 Then Exit Sub
Dim index As Integer
index = index
Dim SelectedRow As DataGridViewRow
SelectedRow = dgvJobsCompleted.Rows(index)
Dim SelectedColumn As DataGridViewCell
SelectedColumn = dgvJobsCompleted.Rows(0).Cells(index)
For Each r As DataRow In SQL.SQLDT.Rows
lbJobCompletedID.Text = r("JobCompletedID").ToString
lbJobID.Text = r("JobID").ToString
lbName.Text = r("Name").ToString
lbHouseNameOrNo.Text = r("HouseNameOrNo").ToString
lbRoadName.Text = r("RoadName").ToString
lbTown.Text = r("Town").ToString
lbCounty.Text = r("County").ToString
lbPostcode.Text = r("Postcode").ToString
lbPriceOfJob.Text = r("PriceOfJob").ToString
lbDiscount.Text = r("Discount").ToString
lbSubTotal.Text = r("SubTotal").ToString
lbVAT.Text = r("VAT").ToString
lbTotalPartsPrice.Text = r("TotalPartsPrice").ToString
lbTotalPrice.Text = r("TotalPrice").ToString
lbUsername.Text = r("Username").ToString
lbDateUpdated.Text = GetDateFromString("DateUpdated").ToString()
Next
End Sub
Kind Regards Gary
Gary Simpson
Continue reading...
On my form I have a DataGridView that I have dragged onto the form via the Data source column, I have also dragged Labels onto the form not all, Only the data I wish to see.
When I click on a row in the DataGridView the Labels work well they show all the data I require.
I also put a textbox on the form to search a particular Column in the DataGridView. this works fine, it narrows down what I am looking/Searching for in the DataGridView.
But here come my issue...
Once I have used the textbox, And I click on the DataGridView row, the Labels are no Longer Updated.
Can someone please help with this Issue
The code from my textbox is...
Private Sub FetchName(Name As String)
SQL.AddParam("@Cust", "%" & Name & "%")
SQL.ExecQuery("Select * FROM JobsCompleted " &
"WHERE Name LIKE @Cust")
dgvJobsCompleted.DataSource = SQL.SQLDT
End Sub
Private Sub txtFilterName_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtFilterName.KeyPress
FetchName(txtFilterName.Text)
End Sub
I have also tried get values from the DataGridView into the Labels with this code. But I still get the same Issue
Private Sub GetName()
SQL.ExecQuery("SELECT * FROM JobsComplete ")
If SQL.RecordCount < 1 Then Exit Sub
Dim index As Integer
index = index
Dim SelectedRow As DataGridViewRow
SelectedRow = dgvJobsCompleted.Rows(index)
Dim SelectedColumn As DataGridViewCell
SelectedColumn = dgvJobsCompleted.Rows(0).Cells(index)
For Each r As DataRow In SQL.SQLDT.Rows
lbJobCompletedID.Text = r("JobCompletedID").ToString
lbJobID.Text = r("JobID").ToString
lbName.Text = r("Name").ToString
lbHouseNameOrNo.Text = r("HouseNameOrNo").ToString
lbRoadName.Text = r("RoadName").ToString
lbTown.Text = r("Town").ToString
lbCounty.Text = r("County").ToString
lbPostcode.Text = r("Postcode").ToString
lbPriceOfJob.Text = r("PriceOfJob").ToString
lbDiscount.Text = r("Discount").ToString
lbSubTotal.Text = r("SubTotal").ToString
lbVAT.Text = r("VAT").ToString
lbTotalPartsPrice.Text = r("TotalPartsPrice").ToString
lbTotalPrice.Text = r("TotalPrice").ToString
lbUsername.Text = r("Username").ToString
lbDateUpdated.Text = GetDateFromString("DateUpdated").ToString()
Next
End Sub
Kind Regards Gary
Gary Simpson
Continue reading...