We often receive requests from our users to resize the FpSpread columns and rows proportionately with the change in Form size. As FpSpread does not have any direct method to achieve the same, this utility blog explains the approach to resize the Columns and Rows as FpSpread is resized along with the form. Implementation is simple and requires handling of Form's Resize event. In this event, each column and row are assigned different width and height respectively, depending on the size of the form that has been resized. Given code snippet shows the implementation of Form's Resize event to calculate the height and width of the rows and cols depending on changing Form dimensions.


void Form1_Resize(object sender, EventArgs e)  
{  
    fpSpread1.Location = new Point(0, 0);  
    fpSpread1.Height = (int)(0.8 * this.Height);  
    fpSpread1.Width = (int)(0.8 * this.Width);  
    int i;  
    float dataareawidth;  
    float rhwidth = 0;  
    float bwidth;  
    float vsbwidth;  
    float dataareaheight;  
    float chheight = 0;  
    float hsbheight;  
    // Horizontal ScrollBar Height  
    bwidth = (2 * SystemInformation.Border3DSize.Width);  
    for (i = 0; (i <= (fpSpread1.Sheets[0].RowHeader.ColumnCount - 1)); i++)  
    {  
      rhwidth += fpSpread1.Sheets[0].RowHeader.Columns[ i ].Width;  
    }  
    vsbwidth = SystemInformation.VerticalScrollBarWidth;  
    dataareawidth = (fpSpread1.Width - (bwidth - (rhwidth - vsbwidth)));  
    for (i = 0; (i <= 3); i++)  
       {  
         // Columns  
         fpSpread1.Sheets[0].Columns[ i ].Width = (dataareawidth / 4);  
       }  
    for (i = 0; (i <= (fpSpread1.Sheets[0].ColumnHeader.RowCount - 1)); i++)  
      {  
         chheight += fpSpread1.Sheets[0].ColumnHeader.Rows[ i ].Height;  
      }  
         hsbheight = SystemInformation.HorizontalScrollBarHeight;  
         dataareaheight = ((float)fpSpread1.Height - (bwidth - (chheight - hsbheight)));  
     for (i = 0; (i <= 9); i++)  
     {  
        // Rows  
     fpSpread1.Sheets[0].Rows[ i ].Height = (dataareaheight / 10);  
     }  
 }  

Refer to the attached samples for detailed implementation. DownloadSample_CS DownloadSample_VB