iBindingList issue with sort to datagridview

  • Thread starter Thread starter guyinkalamazoo3
  • Start date Start date
G

guyinkalamazoo3

Guest
My fellow programmers:

I am getting this error

1491284.png

I am using linq to build the table to bind to the datagridview

Dim logEntries = (From le In coidb.COI_Logs
Where le.LogDate < Now And le.LogDate > DateAdd(DateInterval.Day, -90, Now())
Select New COILogFile With {
.LogID = le.LogID,
.ProcessType = le.ProcessType,
.LogDate = le.LogDate,
.LogNote = le.LogNote,
.LoggedBy = le.LoggedBy}).ToList
dgvLogs.DataSource = logEntries
dgvLogs.Columns(0).Visible = False


What might I be missing here as I want to sort when the column header is clicked and this is the code for that

Dim newColumn As DataGridViewColumn =
dgvLogs.Columns(e.ColumnIndex)
Dim oldColumn As DataGridViewColumn = dgvLogs.SortedColumn
Dim direction As ListSortDirection

If oldColumn IsNot Nothing Then
'sort the same column again, reversing the sort order
If oldColumn Is newColumn AndAlso dgvLogs.SortOrder = SortOrder.Ascending Then
direction = ListSortDirection.Descending
Else
direction = ListSortDirection.Ascending
oldColumn.HeaderCell.SortGlyphDirection = SortOrder.None
End If
Else
direction = ListSortDirection.Ascending
End If

dgvLogs.Sort(newColumn, direction)

If direction = ListSortDirection.Ascending Then
newColumn.HeaderCell.SortGlyphDirection = SortOrder.Ascending
Else
newColumn.HeaderCell.SortGlyphDirection = SortOrder.Descending
End If
End Sub

Thanks


Brad Allison

Continue reading...
 
Back
Top