views:

371

answers:

2

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.

A: 

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.

And for fun, check the other versions of this answer to see my first (overcomplicated) solution.. ;)

Stefan
A: 

Go home and forget it.