From 385ad98d951fab0c8e70db29f9606587e1b843e3 Mon Sep 17 00:00:00 2001 From: Jonathan Jenne Date: Wed, 21 Apr 2021 14:31:39 +0200 Subject: [PATCH] Common: Custom Draw Cell in catch block --- .../frmDocumentResultList.vb | 32 +++++++++++-------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/GUIs.Common/DocumentResultList/frmDocumentResultList.vb b/GUIs.Common/DocumentResultList/frmDocumentResultList.vb index 57cd5001..dc812daa 100644 --- a/GUIs.Common/DocumentResultList/frmDocumentResultList.vb +++ b/GUIs.Common/DocumentResultList/frmDocumentResultList.vb @@ -560,24 +560,28 @@ Public Class frmDocumentResultList End Sub Private Sub GridView1_CustomDrawCell(sender As Object, e As RowCellCustomDrawEventArgs) Handles GridView1.CustomDrawCell - If e.RowHandle < 0 Then - Exit Sub - End If + Try + If e.RowHandle < 0 Then + Exit Sub + End If - Dim oView As GridView = TryCast(sender, GridView) - Dim oCellInfo As GridCellInfo = TryCast(e.Cell, GridCellInfo) - Dim oRow As DataRow = oView.GetDataRow(e.RowHandle) - Dim oValue = oRow.Item(COLUMN_FILENAME) + e.DefaultDraw() - e.DefaultDraw() + Dim oView As GridView = TryCast(sender, GridView) + Dim oCellInfo As GridCellInfo = TryCast(e.Cell, GridCellInfo) + Dim oRow As DataRow = oView.GetDataRow(e.RowHandle) + Dim oValue = oRow.Item(COLUMN_FILENAME) - If e.Column.FieldName = COLUMN_ICON Then - Dim oIcon = _Helpers.GetIconByExtension(oValue) - Dim offsetX = 0 - Dim offsetY = 0 + If e.Column.FieldName = COLUMN_ICON Then + Dim oIcon = _Helpers.GetIconByExtension(oValue) + Dim offsetX = 0 + Dim offsetY = 0 - e.Cache.DrawImage(oIcon, e.Bounds.X + offsetX, e.Bounds.Y + offsetY, 18, 18) - End If + e.Cache.DrawImage(oIcon, e.Bounds.X + offsetX, e.Bounds.Y + offsetY, 18, 18) + End If + Catch ex As Exception + _Logger.Error(ex) + End Try End Sub Private Function TryGetItem(DataRow As DataRow, ColumnName As String, Optional DefaultValue As String = "") As String