Welcome,
 Guest User.

  Click to Login   


 FarPoint HOME
 clubFarPoint HOME

SUPPORT
   Forum
   View Your Questions

RESOURCES
   Search
   Articles
   Product Docs
   FAQ
   Training Videos
   Feature Suggestions
   Subscriptions
   User Groups
   FarPoint Blog

DOWNLOAD
   Updates
   Trials

MY ACCOUNT
   Member Benefits
   MVP Status
   RSS Feeds
   Register Product
   View Products
   View Orders
   Order Now
   My Profile
   Product Profiles

   clubFarPoint Feedback...


There are 9 registered members online.


   

Articles
<< Return to Articles
Getting Left and Right Bounding Coordinates for Columns
Submitted By: JSchn Last Updated: 10/10/2005 10:29:32 AM
Level: Intermediate  
Product(s): Spread for Windows Forms 2  
Language(s): C#  
Description: This code sample demonstrates how to get the bounding left and right x-coordinate for a given column, even if no data cells on that column are currently visible on the Spread.  
 

Introduction

This method is written to be used in a derived class of FpSpread. Although I haven't tried it, I suspect the method could also be used in a class that references an FpSpread (changing "this." to "this.fpSpread1.", etc.)

Note that if it is known that at least one row of data cells is visible on the Spread for the column, the spreadView.GetCellRectangle method can be called on a data cell in the column to get the left and right bounds for the column instead of using this approach.

Code

  public void GetColumnLeftRightBounds(int columnIndex, int viewportColumnIndex, out int leftBound, out int rightBound)
  {
   SpreadView spreadView = GetRootWorkbook();
   
   int leftColumnIndexInViewport = spreadView.GetViewportLeftColumn(viewportColumnIndex);
   int rightColumnIndexInViewport = spreadView.GetViewportRightColumn(viewportColumnIndex);

   if (leftColumnIndexInViewport > columnIndex || rightColumnIndexInViewport < columnIndex)
   {
    throw new ArgumentOutOfRangeException("The specified column index, " + columnIndex
      + ", is not visible in the specified viewport column, " + viewportColumnIndex + ".  "
      + "Columns in range are " + leftColumnIndexInViewport + " through " + rightColumnIndexInViewport + ".");
   }
   
   int currentColumnIndex = leftColumnIndexInViewport;
   rightBound = spreadView.GetViewportX(viewportColumnIndex);
   do
   {
    leftBound = rightBound;
    rightBound = leftBound + (int)(this.Sheets[0].Columns[currentColumnIndex].Width * this.ZoomFactor);
    currentColumnIndex++;
   } while (currentColumnIndex <= columnIndex);
  }

 


   

Subscribe to the RSS feed!RSS Subscribe


Click for Morrisville, North Carolina Forecast
 
Todays Trivia














FarPoint's Spread for Web Forms

     About Us | Contact UsComments & Suggestions | ©2008 FarPoint Technologies, Inc.