I am working on a form and have to make sure that the columns all are the correct width for the maximum data that can be entered. Some cols may have data like “111” (which will require a wider column for “333”. Some cols may have “9999.9”. So in order to properly set the sizes, I created a handly little function that will not be on in run time, only design time. It just tells me what I have resized the column widths to, so that I can go back and apply the correct widths in my grid formatting code.
Private Sub UltraGrid1_AfterColPosChanged(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinGrid.AfterColPosChangedEventArgs) Handles UltraGrid1.AfterColPosChanged
MessageBox.Show(“col width=” & e.ColumnHeaders(0).Column.Width)
If you have a boolean that indicates you are loading the form, you might want to wrap that around the messagebox function so you don’t get a popup for each cell as the form is rendering.
Not earth shattering, but a nice trick instead of guessing!
Sign up for my newsletter so you don't miss my conference & Pluralsight course announcements!