New User (1st day)

Posted by: pbright-fp on 8 September 2017, 2:21 pm EST

  • Posted 8 September 2017, 2:21 pm EST

    I have gone through the documentation and was able to get this compoent to do everything that I wanted..  WOW


    However the very last thing..LOL... I can not figure out...


    I want to jump to a specific Cell in the active sheet at runtime and I need the active sheet to move to that position on screen if that cell is off screen and it needs to be highlighted that it is the selected cell.


    I thought this would do it but nothing happens....


    fpSpread1.ActiveSheet.SetActiveCell(1000, 1); 


     Can someone help...

  • Replied 8 September 2017, 2:21 pm EST

    Hello,

    After setting the cell as active you may show the cell using ShowActiveCell() method.

    e.g.

    fpSpread1.ShowActiveCell(FarPoint.Win.Spread.VerticalPosition.Center, FarPoint.Win.Spread.HorizontalPosition.Center)

     

    I hope it will help you.

    Thanks,

     


     

     

  • Replied 8 September 2017, 2:21 pm EST

    Worked Perfectly!!!  Thanks yoo so much..... 


    How do you highlight the selected cell you just jumped to?   It's now moving to the position but there is no indicator in the cell of what that positon is...

  • Replied 8 September 2017, 2:21 pm EST

    This most likely is not the best way .. but only been in this component one day ..  LOL 


     private void MoveToActiveCell(
        int row,
               int col,
                System.Drawing.Color InActiveCelBackgroundColor,
                System.Drawing.Color InActiveCelFontColor,
                System.Drawing.Color ActiveCelBackgroundColor,
                System.Drawing.Color ActiveCelFontColor)
     {
                //set previous selected cell back to normal
                fpSpread1.ActiveSheet.ActiveCell.BackColor = InActiveCelBackgroundColor;
                fpSpread1.ActiveSheet.ActiveCell.ForeColor = InActiveCelFontColor;


                //set active row and column
                fpSpread1.ActiveSheet.ActiveRowIndex = row;
                fpSpread1.ActiveSheet.ActiveColumnIndex = col;


                //set active cell
                fpSpread1.ActiveSheet.SetActiveCell(row, col);


               //move to location
                fpSpread1.ShowActiveCell(
                             FarPoint.Win.Spread.VerticalPosition.Center,
                             FarPoint.Win.Spread.HorizontalPosition.Center);


                //set new active cell color
                fpSpread1.ActiveSheet.ActiveCell.BackColor = ActiveCelBackgroundColor;
                fpSpread1.ActiveSheet.ActiveCell.ForeColor = ActiveCelFontColor;

  • Replied 8 September 2017, 2:21 pm EST

    Hello,

    You can use the following code to highlight the selected cell only with BackColor and Border and then restoring the default BackColor and Border on leaving the cell. Code for the same is given below:

            FarPoint.Win.BevelBorder bevelbrdr = new FarPoint.Win.BevelBorder(FarPoint.Win.BevelBorderType.Raised, Color.Cyan, Color.DarkCyan);
            private void fpSpread1_LeaveCell(object sender, FarPoint.Win.Spread.LeaveCellEventArgs e)
            {
                fpSpread1.Sheets[0].Cells[e.NewRow, e.NewColumn].BackColor = Color.Red;
                fpSpread1.Sheets[0].Cells[e.NewRow, e.NewColumn].Border = bevelbrdr;
                fpSpread1.Sheets[0].Cells[e.Row, e.Column].BackColor = fpSpread1_Sheet1.DefaultStyle.BackColor;
                fpSpread1.Sheets[0].Cells[e.Row, e.Column].Border = null;
            }
            private void fpSpread1_Leave(object sender, EventArgs e)
            {
                fpSpread1.Sheets[0].ActiveCell.BackColor = fpSpread1_Sheet1.DefaultStyle.BackColor;
                fpSpread1.Sheets[0].ActiveCell.Border = null;
            }
            private void fpSpread1_Enter(object sender, EventArgs e)
            {
                fpSpread1.Sheets[0].ActiveCell.BackColor = Color.Red;
                fpSpread1.Sheets[0].ActiveCell.Border = bevelbrdr;
            }

    Hope this will help you. Thanks.

  • Replied 8 September 2017, 2:21 pm EST

    Thanks!!!!
Need extra support?

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

Learn More

Forum Channels