Change the progress bar height

Posted by: satson90 on 8 September 2017, 3:08 pm EST

  • Posted 8 September 2017, 3:08 pm EST

    Hi 

    In Speard sheet i want to show the progressbar. row height is 40 so the progress bar show that much height. how to reduce the progress bar height and show in the center of the cell. How can i acheive this. i am using progressbar cell type 

  • Replied 8 September 2017, 3:08 pm EST

    Hello,

    You need to create a CustomCelltype for that matter and have to adjust the rectangle size depending on your requirement. Please have a look at the below mentioned code for that matter:-

    class CustomProgressBar : FarPoint.Win.Spread.CellType.ProgressCellType
        {
            public override void PaintCell(System.Drawing.Graphics g, System.Drawing.Rectangle r, FarPoint.Win.Spread.Appearance appearance, object value, bool isSelected, bool isLocked, float zoomFactor)
            {
                base.PaintCell(g, new Rectangle(r.Right - 37, r.Y, 17, r.Height - 7), appearance, value, isSelected, isLocked, zoomFactor); // Here adjust the rectangle size
            }
        }

            private void Form1_Load(object sender, EventArgs e)
            {
                CustomProgressBar cus = new CustomProgressBar();
                fpSpread1.ActiveSheet.Cells[1, 1].CellType = cus;
                fpSpread1.ActiveSheet.Cells[1, 1].Value = 30;
            }

    Hope it helps.

    Thanks,

    Reeva

  • Replied 8 September 2017, 3:08 pm EST

    Hi i am try this but its not wroking what am doing wrong?

       Dim xProgress As New CustomProgress 

    xProgress.Maximum = xDrive.TotalSize / 1073741824

                            xProgress.Minimum = 0

                            xProgress.FillColor = Color.Green

                            xProgress.Style = FarPoint.Win.ProgressStyle.Default

                            .Cells(.RowCount - 1, .Columns("Progresscol").Index).CellType = xProgress

                            .Cells(.RowCount - 1, .Columns("Progresscol").Index).Value = (xDrive.TotalSize - xDrive.TotalFreeSpace) / 1073741824

                            .Rows(.RowCount - 1).Height = 40 

     

    Public Class CustomProgress

        Inherits FarPoint.Win.Spread.CellType.ProgressCellType


        Public Overrides Sub PaintCell(ByVal g As FarPoint.PDF.PdfGraphics, ByVal r As System.Drawing.RectangleF, ByVal appearance As FarPoint.Win.Spread.Appearance, ByVal value As Object, ByVal isSelected As Boolean, ByVal isLocked As Boolean, ByVal zoomFactor As Single)

            MyBase.PaintCell(g, r, appearance, value, isSelected, isLocked, zoomFactor)


            MyBase.PaintCell(g, New Rectangle(r.Right - 37, r.Y, 17, r.Height - 7), appearance, value, isSelected, isLocked, zoomFactor)


        End Sub 

  • Replied 8 September 2017, 3:08 pm EST

    Hello,

    You are overriding a wrong method. Please have a look at the attached sample in VB.Net for complete implementation of the same.

    Hope it helps.

    Thanks,

    Reeva


    2013/06/CustomProgressBar_VB.zip
  • Replied 8 September 2017, 3:08 pm EST

    Thanks Reeva.

    Its Work well

     

Need extra support?

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

Learn More

Forum Channels