Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Best Form Event to put Code in

Posted on 2009-04-20
Medium Priority
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
  • 3
LVL 33

Expert Comment

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

Expert Comment

ID: 24188399
Can you post a sample code please?

Author Comment

ID: 24189683

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

jppinto earned 2000 total points
ID: 24189901
Try the solution presented here byy jpaulino:


This maybe what you need.


Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
The Relationships Diagram is a good way to get an overall view of what a database is keeping track of. It is also where relationships are defined. A relationship specifies how two tables connect to each other. As you build tables in Microsoft Ac…

571 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