Best Form Event to put Code in

Posted on 2009-04-20
Last Modified: 2012-05-06
I have a form with multiple fpspread grids.  
When my form loads it loads maximized and although my anchor property is not set to expand, the grids still do.
I have some code that resizes the last column in the grid so it expands to the lenth of the grid.
I need to put this code in an event that won't fire until the controls have all been drawn and resized.
What would be the best event?
Question by:Sheritlw
    LVL 33

    Expert Comment

    Did you've tryed the form_Load() event?
    LVL 33

    Expert Comment

    Can you post a sample code please?

    Author Comment


    Below resizes the last column of each grid so that the column will extend out to the edge of the grid.
    I have a collection that holds all my grids and would like a form event to run this, so I don't have to send each one seperatly.
    If used in the load event the controls haven't been resized/painted yet.

      Private Sub ResizeGridColumns(ByVal cnt As FarPoint.Win.Spread.FpSpread)
            Dim iTotSize As Integer
            Dim iCol As Integer
            Dim i As Integer
            Dim iPad As Integer = 0
            Dim iScrollWidth As Integer = 0
            Dim cnt As FarPoint.Win.Spread.FpSpread
    For each cnt in FGrd '(Collection of my spread grids)

                i = cnt.ActiveSheet.RowHeader.Columns(0).Width

                For iCol = 1 To cnt.ActiveSheet.Columns.Count - 2
                    iTotSize += cnt.ActiveSheet.Columns(iCol).Width

                If (cnt.BorderStyle = BorderStyle.Fixed3D) Then
                    iPad = 4
                End If

                If (cnt.VerticalScrollBarPolicy = FarPoint.Win.Spread.ScrollBarPolicy.Always Or cnt.VerticalScrollBarPolicy = FarPoint.Win.Spread.ScrollBarPolicy.AsNeeded) Then
                    iScrollWidth = cnt.VerticalScrollBarWidth
                End If

                cnt.ActiveSheet.Columns(cnt.ActiveSheet.Columns.Count - 1).Width = cnt.Width - (iTotSize + i + iPad + iScrollWidth)

    next cnt

        End Sub

    LVL 33

    Accepted Solution

    Try the solution presented here byy jpaulino:

    This maybe what you need.


    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
    Article by: Kraeven
    Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now