T Hoecherl
asked on
vb.net. Launching code after the column header has been clicked to sort
I want this code to be executed, every time a column header has been clicked to sort the column:
Dim intRows As Integer
intRows = dgvProdBatch.Rows.Count - 2
dgvProdBatch.Rows(intRows) .DefaultCe llStyle.Fo reColor = Color.White
dgvProdBatch.Rows(intRows) .Cells(7). Style.Fore Color = Color.Red
dgvProdBatch.Rows(intRows) .Cells(8). Style.Fore Color = Color.Red
This is what I tried, but this code doesn't ever execute:
Private Sub dgvprodbatch_columnheaderm ouseclick( ByVal sender As Object, ByVal e As DataGridViewCellMouseEvent Args)
Dim intRows As Integer
intRows = dgvProdBatch.Rows.Count - 2
dgvProdBatch.Rows(intRows) .DefaultCe llStyle.Fo reColor = Color.White
dgvProdBatch.Rows(intRows) .Cells(7). Style.Fore Color = Color.Red
dgvProdBatch.Rows(intRows) .Cells(8). Style.Fore Color = Color.Red
End Sub
How can I accomplish this task?
Dim intRows As Integer
intRows = dgvProdBatch.Rows.Count - 2
dgvProdBatch.Rows(intRows)
dgvProdBatch.Rows(intRows)
dgvProdBatch.Rows(intRows)
This is what I tried, but this code doesn't ever execute:
Private Sub dgvprodbatch_columnheaderm
Dim intRows As Integer
intRows = dgvProdBatch.Rows.Count - 2
dgvProdBatch.Rows(intRows)
dgvProdBatch.Rows(intRows)
dgvProdBatch.Rows(intRows)
End Sub
How can I accomplish this task?
I enable sorting in the datagrid properties
ASKER
I have already done that and the columns sort properly. That's not the problem. But each time any column is sorted, after the sort is finished, I want the font color of the last row to be reset. Hence, the code:
Dim intRows As Integer
intRows = dgvProdBatch.Rows.Count - 2
dgvProdBatch.Rows(intRows) .DefaultCe llStyle.Fo reColor = Color.White
dgvProdBatch.Rows(intRows) .Cells(7). Style.Fore Color = Color.Red
dgvProdBatch.Rows(intRows) .Cells(8). Style.Fore Color = Color.Red
What I don't know how to do is recognize the sorting process as an event that I can use to launch this code.
Dim intRows As Integer
intRows = dgvProdBatch.Rows.Count - 2
dgvProdBatch.Rows(intRows)
dgvProdBatch.Rows(intRows)
dgvProdBatch.Rows(intRows)
What I don't know how to do is recognize the sorting process as an event that I can use to launch this code.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you David. That did it.