Datagridview - check if the last column is fully displayed
I was wondering if there was a way to determine if the last column is fully displayed.
I know there is a Displayed property on a column, but that property is true if the column is either partially or fully displayed. I only want it if the column is fully displayed.
This will do it:
Function IsFullyVisible(ByVal dg As DataGridView, ByVal columnindex As Integer) As Boolean Return dg.GetColumnDisplayRectangle(columnindex, False).Width = dg.GetColumnDisplayRectangle(columnindex, True).Width End Function
Call it by IsFullyVisible(DataGridView1, DataGridView1.ColumnCount - 1) to get if the last column is fully visible.