Change Event Handler

The code example in Listing 7.31 resizes the columns in the list object whenever the Change event is raised. In this way, if you type information that does not fit the width of the column, the column automatically resizes to fit the text when you move your cursor to a new cell in the list object.

Listing 7.31. Resizing the list object whenever data is changed

Private Sub List1_Change(ByVal targetRange As _

Microsoft.Office.Interop.Excel.Range, ByVal changedRanges _ As Microsoft.Office.Tools.Excel.ListRanges) Handles _ List1.Change

Me.Columns.AutoFit()

End Sub

0 0

Post a comment