rmclean
Member
- Joined
- Apr 15, 2010
- Messages
- 6
- Programming Experience
- 1-3
I have datagridview that is bound to a datasource (SQL Server table). I added some code to the cell_formatting event that makes text in 2 columns appear stacked (code below). Since I added this formatting, any attempt to resize a column or sort a column is painfully slow. Prior to adding the code, it reacted very quickly to either column resizing or sorting. Any advice on settings or anything else I can check to try and improve performance?
VB.NET:
Private Sub dgvRecords_CellFormatting(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellFormattingEventArgs) Handles dgvRecords.CellFormatting
If e.ColumnIndex = 3 Then
Dim strValue As String = TryCast(e.Value, String)
If strValue Is Nothing Then Return
strValue = CStr(dgvRecords.Item(e.ColumnIndex, e.RowIndex).Value)
Dim strArray As String = strValue.Replace(" ", Environment.NewLine)
e.Value = strArray
End If
If e.ColumnIndex = 5 Then
Dim strValue As String = TryCast(e.Value, String)
If strValue Is Nothing Then Return
strValue = CStr(dgvRecords.Item(e.ColumnIndex, e.RowIndex).Value)
Dim strArray As String = strValue.Replace(" ", Environment.NewLine)
e.Value = strArray
End If
End Sub
Last edited by a moderator: