Background Click Event

Posted by: superjason on 8 September 2017, 12:31 pm EST

  • Posted 8 September 2017, 12:31 pm EST

    Is there an event that's fired when the user clicks on the background (the area behind the grid, but still within the control)?
  • Replied 8 September 2017, 12:31 pm EST

    Hello,



    The only event that will fire is the MouseDown event.



    This event fires anytime you do a mousedown over the control, but you
    could use the coordinates of e, the width and height of the control and
    the SystemInformation.VerticalScrollBarWidth and
    SystemInformation.HorizontalScrollBarHeight to determine if you clicked
    in the area in the bottom right of the control(background area).
  • Replied 8 September 2017, 12:31 pm EST

           Like this: 
            Dim sprwidth As Integer = FpSpread1.Width
    Dim sprheight As Integer = FpSpread1.Height
     
  • Replied 8 September 2017, 12:31 pm EST

    Hello,

    I reread your post and I think you may be refering to just the rows and columns portion of the control, not the entire control. If you want the height and width of those, you would have to loop through the rows and columns and get the height and width of each and increment a variable during each loop.

    For example: 
            Dim w As Integer
    For i As Integer = 0 To FpSpread1.Sheets(0).ColumnCount - 1
    w += FpSpread1.Sheets(0).Columns(i).Width
    Next

    Dim h As Integer
    For x As Integer = 0 To FpSpread1.Sheets(0).RowCount - 1
    h += FpSpread1.Sheets(0).Rows(x).Height
    Next
     
  • Replied 8 September 2017, 12:31 pm EST

    Jason -

    In case you were wanting just the width and height of the actual grid and not the container you could use code similiar to this...

    Dim r, c, w, h As Integer

    For r = 0 To FpSpread1.ActiveSheet.RowCount - 1
    h += FpSpread1.ActiveSheet.Rows(i).Height


    Next

    h += FpSpread1.ActiveSheet.ColumnHeader.Rows(0).Height


    For c = 0 To FpSpread1.ActiveSheet.ColumnCount - 1
    w += FpSpread1.ActiveSheet.Columns(i).Width


    Next

    w += FpSpread1.ActiveSheet.RowHeader.Columns(0).Width

    If you don't want to include the headers in your calculation then remove that code.
  • Replied 8 September 2017, 12:31 pm EST

    Thanks.  I was about to ask you what the heck you were thinking.  I'll give this new method a try.
  • Replied 8 September 2017, 12:31 pm EST

    Here is the code I used if anyone else is interested:

     
    		private Rectangle getGridDimensions()
    {
    double height;
    double width;

    height = _sheet.ColumnHeader.Rows[0].Height;
    foreach(Row currRow in _sheet.Rows)
    height += currRow.Height;

    width = _sheet.RowHeader.Columns[0].Width;
    foreach (Column currCol in _sheet.Columns)
    width += currCol.Width;

    return new Rectangle(0, 0, (int)Math.Round(width), (int)Math.Round(height));
    }
     
  • Replied 8 September 2017, 12:31 pm EST

    How do I know the height and width of the actual grid (and not the background)?
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels