add text to background

Posted by: parez81-fp on 8 September 2017, 1:15 pm EST

  • Posted 8 September 2017, 1:15 pm EST

    Hi


    how do i add text to the background of the grid. I am pretty sure background is not the right word.
    Its the area that you seen when there are no rows in the grid.
    I want to display message like "No rows found";
  • Replied 8 September 2017, 1:15 pm EST

    Paresh,


    I ran the code through a VB to C# converter (for time constraints) and have not tested this, but it looks correct.

     
    public class myIFR : FarPoint.Win.Spread.IInterfaceRenderer 
    {

    FarPoint.Win.Spread.EnhancedInterfaceRenderer enhR = new FarPoint.Win.Spread.EnhancedInterfaceRenderer();

    public void FarPoint.Win.Spread.IInterfaceRenderer.PaintButton(System.Drawing.Graphics g, int x, int y, int width, int height, FarPoint.Win.Spread.TabStripButton button, bool mouseOver, bool pressed, bool isLeftToRight, bool enabled
    )
    {
    enhR.PaintButton(g, x, y, width, height, button, mouseOver, pressed, isLeftToRight, enabled
    );
    }

    public void FarPoint.Win.Spread.IInterfaceRenderer.PaintGrayArea(System.Drawing.Graphics g, int x, int y, int width, int height)
    {
    g.DrawString("No Rows To Display", new Font("Arial", 14, FontStyle.Bold), Brushes.Red, 300, 50);
    }

    public void FarPoint.Win.Spread.IInterfaceRenderer.PaintRangeGroupArea(System.Drawing.Graphics g, int x, int y, int width, int height)
    {
    enhR.PaintRangeGroupArea(g, x, y, width, height);
    }

    public void FarPoint.Win.Spread.IInterfaceRenderer.PaintRangeGroupButton(System.Drawing.Graphics g, int x, int y, int width, int height, FarPoint.Win.Spread.GroupState groupState, bool rowGroup, bool isLeftToRight)
    {
    enhR.PaintRangeGroupButton(g, x, y, width, height, groupState, rowGroup, isLeftToRight);
    }

    public void FarPoint.Win.Spread.IInterfaceRenderer.PaintRangeGroupLevelBox(System.Drawing.Graphics g, int x, int y, int width, int height, int groupLevel, bool rowGroup, bool isLeftToRight)
    {
    enhR.PaintRangeGroupLevelBox(g, x, y, width, height, groupLevel, rowGroup, isLeftToRight);
    }

    public void FarPoint.Win.Spread.IInterfaceRenderer.PaintRangeGroupLine(System.Drawing.Graphics g, System.Drawing.Point startPoint, System.Drawing.Point endPoint)
    {
    enhR.PaintRangeGroupLine(g, startPoint, endPoint);
    }

    public void FarPoint.Win.Spread.IInterfaceRenderer.PaintRangeGroupPoint(System.Drawing.Graphics g, System.Drawing.Point point)
    {
    enhR.PaintRangeGroupPoint(g, point);
    }

    public void FarPoint.Win.Spread.IInterfaceRenderer.PaintScrollBox(System.Drawing.Graphics g, int x, int y, int width, int height)
    {
    enhR.PaintScrollBox(g, x, y, width, height);
    }

    public void FarPoint.Win.Spread.IInterfaceRenderer.PaintSheetTab(System.Drawing.Graphics g, int sheet, string text, int x, int y, int width, int height, bool mouseOver, bool focused, FarPoint.Win.Spread.TabStripPlacement placement,
    bool isLeftToRight, bool enabled, System.Drawing.Font font, System.Drawing.Font activeFont)
    {
    enhR.PaintSheetTab(g, sheet, text, x, y, width, height, mouseOver, focused, placement,
    isLeftToRight, enabled, font, activeFont);
    }

    public void FarPoint.Win.Spread.IInterfaceRenderer.PaintSheetTabPartial(System.Drawing.Graphics g, int sheet, string text, int x, int y, int width, int height, bool mouseOver, bool focused, FarPoint.Win.Spread.TabStripPlacement placement,
    bool isLeftToRight, bool enabled, System.Drawing.Font font, System.Drawing.Font activeFont)
    {
    enhR.PaintSheetTabPartial(g, sheet, text, x, y, width, height, mouseOver, focused, placement,
    isLeftToRight, enabled, font, activeFont);
    }

    public void FarPoint.Win.Spread.IInterfaceRenderer.PaintSpecialSheetTab(System.Drawing.Graphics g, int x, int y, int width, int height, bool mouseOver, FarPoint.Win.Spread.TabStripPlacement placementbStrip, bool isLeftToRight, bool enabled, System.Drawing.Font font,
    System.Drawing.Font activeFont)
    {
    enhR.PaintSpecialSheetTab(g, x, y, width, height, mouseOver, placementbStrip, isLeftToRight, enabled, font,
    activeFont);
    }

    public void FarPoint.Win.Spread.IInterfaceRenderer.PaintSplitBar(System.Drawing.Graphics g, int x, int y, int width, int height)
    {
    enhR.PaintSplitBar(g, x, y, width, height);
    }

    public void FarPoint.Win.Spread.IInterfaceRenderer.PaintSplitBarCrossover(System.Drawing.Graphics g, int x, int y, int width, int height)
    {
    enhR.PaintSplitBarCrossover(g, x, y, width, height);
    }

    public void FarPoint.Win.Spread.IInterfaceRenderer.PaintSplitBox(System.Drawing.Graphics g, int x, int y, int width, int height)
    {
    enhR.PaintSplitBox(g, x, y, width, height);
    }

    public void FarPoint.Win.Spread.IInterfaceRenderer.PaintTabStripBackground(System.Drawing.Graphics g, int x, int y, int width, int height, FarPoint.Win.Spread.TabStripPlacement placement)
    {
    enhR.PaintTabStripBackground(g, x, y, width, height, placement);
    }
    }
     
  • Replied 8 September 2017, 1:15 pm EST

    Thanks for the code..

    I am having a problem. I have the following code in the PaintGrayArea function.
    After I click a button , I set the SpreadStatus to SpreadMessageStatus.Processing. and then i show MessageBox  with yes no buttons. if you click no ,then i set the status to RequestCanceled.
    I have attached a screen shot of the problem." processed.Please wait" from the previous message is still there.



                renderer.PaintGrayArea(g, x, y, width, height);
                string message=null;
                Brush brush = Brushes.SeaGreen;
                switch (this.SpreadStatus)
                {
                    case SpreadMessageStatus.Custom:
                        message = this.CustomMessage;
                        break;
                    case SpreadMessageStatus.NoRowsFound:
                        message = "No Records Found";
                        brush = Brushes.Red;
                        break;
                    case SpreadMessageStatus.Processing:
                        message = "This request is being processed.Please wait";
                        break;
                    case SpreadMessageStatus.RequestCanceled:
                        message = "The last request was cancelled.";
                        break;
                    case SpreadMessageStatus.NoMessage:
                        message = "";
                        break;
                    default:
                        message = "";
                        break;
                }

                if (this.Spread.ActiveSheet.RowCount == 0)
                    g.DrawString(message, new Font("Arial", 12, FontStyle.Bold), brush, 250, 50);



    2008/05/cancelled.JPG
  • Replied 8 September 2017, 1:15 pm EST

    Hello,


    Are you redrawing the grayarea after the messagebox? This should get rid of the first message.

  • Replied 8 September 2017, 1:15 pm EST

    Hello,


    You can implement your own IInterfaceRenderer and in the PaintGrayArea method draw whatever you want.

     
      Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    FpSpread1.InterfaceRenderer = New myIFR
    End Sub

    Private Sub
    Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
    FpSpread1.Sheets(0).RowCount = 0
    End Sub

    Public Class
    myIFR
    Implements FarPoint.Win.Spread.IInterfaceRenderer

    Dim enhR As New FarPoint.Win.Spread.EnhancedInterfaceRenderer

    Public Sub PaintButton(ByVal g As System.Drawing.Graphics, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal button As FarPoint.Win.Spread.TabStripButton, ByVal mouseOver As Boolean, ByVal pressed As Boolean, ByVal isLeftToRight As Boolean, ByVal enabled As Boolean) Implements FarPoint.Win.Spread.IInterfaceRenderer.PaintButton
    enhR.PaintButton(g, x, y, width, height, button, mouseOver, pressed, isLeftToRight, enabled)
    End Sub

    Public Sub
    PaintGrayArea(ByVal g As System.Drawing.Graphics, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer) Implements FarPoint.Win.Spread.IInterfaceRenderer.PaintGrayArea
    g.DrawString("No Rows To Display", New Font("Arial", 14, FontStyle.Bold), Brushes.Red, 300, 50)
    End Sub

    Public Sub
    PaintRangeGroupArea(ByVal g As System.Drawing.Graphics, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer) Implements FarPoint.Win.Spread.IInterfaceRenderer.PaintRangeGroupArea
    enhR.PaintRangeGroupArea(g, x, y, width, height)
    End Sub

    Public Sub
    PaintRangeGroupButton(ByVal g As System.Drawing.Graphics, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal groupState As FarPoint.Win.Spread.GroupState, ByVal rowGroup As Boolean, ByVal isLeftToRight As Boolean) Implements FarPoint.Win.Spread.IInterfaceRenderer.PaintRangeGroupButton
    enhR.PaintRangeGroupButton(g, x, y, width, height, groupState, rowGroup, isLeftToRight)
    End Sub

    Public Sub
    PaintRangeGroupLevelBox(ByVal g As System.Drawing.Graphics, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal groupLevel As Integer, ByVal rowGroup As Boolean, ByVal isLeftToRight As Boolean) Implements FarPoint.Win.Spread.IInterfaceRenderer.PaintRangeGroupLevelBox
    enhR.PaintRangeGroupLevelBox(g, x, y, width, height, groupLevel, rowGroup, isLeftToRight)
    End Sub

    Public Sub
    PaintRangeGroupLine(ByVal g As System.Drawing.Graphics, ByVal startPoint As System.Drawing.Point, ByVal endPoint As System.Drawing.Point) Implements FarPoint.Win.Spread.IInterfaceRenderer.PaintRangeGroupLine
    enhR.PaintRangeGroupLine(g, startPoint, endPoint)
    End Sub

    Public Sub
    PaintRangeGroupPoint(ByVal g As System.Drawing.Graphics, ByVal point As System.Drawing.Point) Implements FarPoint.Win.Spread.IInterfaceRenderer.PaintRangeGroupPoint
    enhR.PaintRangeGroupPoint(g, point)
    End Sub

    Public Sub
    PaintScrollBox(ByVal g As System.Drawing.Graphics, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer) Implements FarPoint.Win.Spread.IInterfaceRenderer.PaintScrollBox
    enhR.PaintScrollBox(g, x, y, width, height)
    End Sub

    Public Sub
    PaintSheetTab(ByVal g As System.Drawing.Graphics, ByVal sheet As Integer, ByVal text As String, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal mouseOver As Boolean, ByVal focused As Boolean, ByVal placement As FarPoint.Win.Spread.TabStripPlacement, ByVal isLeftToRight As Boolean, ByVal enabled As Boolean, ByVal font As System.Drawing.Font, ByVal activeFont As System.Drawing.Font) Implements FarPoint.Win.Spread.IInterfaceRenderer.PaintSheetTab
    enhR.PaintSheetTab(g, sheet, text, x, y, width, height, mouseOver, focused, placement, isLeftToRight, enabled, font, activeFont)
    End Sub

    Public Sub
    PaintSheetTabPartial(ByVal g As System.Drawing.Graphics, ByVal sheet As Integer, ByVal text As String, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal mouseOver As Boolean, ByVal focused As Boolean, ByVal placement As FarPoint.Win.Spread.TabStripPlacement, ByVal isLeftToRight As Boolean, ByVal enabled As Boolean, ByVal font As System.Drawing.Font, ByVal activeFont As System.Drawing.Font) Implements FarPoint.Win.Spread.IInterfaceRenderer.PaintSheetTabPartial
    enhR.PaintSheetTabPartial(g, sheet, text, x, y, width, height, mouseOver, focused, placement, isLeftToRight, enabled, font, activeFont)
    End Sub

    Public Sub
    PaintSpecialSheetTab(ByVal g As System.Drawing.Graphics, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal mouseOver As Boolean, ByVal placementbStrip As FarPoint.Win.Spread.TabStripPlacement, ByVal isLeftToRight As Boolean, ByVal enabled As Boolean, ByVal font As System.Drawing.Font, ByVal activeFont As System.Drawing.Font) Implements FarPoint.Win.Spread.IInterfaceRenderer.PaintSpecialSheetTab
    enhR.PaintSpecialSheetTab(g, x, y, width, height, mouseOver, placementbStrip, isLeftToRight, enabled, font, activeFont)
    End Sub

    Public Sub
    PaintSplitBar(ByVal g As System.Drawing.Graphics, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer) Implements FarPoint.Win.Spread.IInterfaceRenderer.PaintSplitBar
    enhR.PaintSplitBar(g, x, y, width, height)
    End Sub

    Public Sub
    PaintSplitBarCrossover(ByVal g As System.Drawing.Graphics, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer) Implements FarPoint.Win.Spread.IInterfaceRenderer.PaintSplitBarCrossover
    enhR.PaintSplitBarCrossover(g, x, y, width, height)
    End Sub

    Public Sub
    PaintSplitBox(ByVal g As System.Drawing.Graphics, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer) Implements FarPoint.Win.Spread.IInterfaceRenderer.PaintSplitBox
    enhR.PaintSplitBox(g, x, y, width, height)
    End Sub

    Public Sub
    PaintTabStripBackground(ByVal g As System.Drawing.Graphics, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal placement As FarPoint.Win.Spread.TabStripPlacement) Implements FarPoint.Win.Spread.IInterfaceRenderer.PaintTabStripBackground
    enhR.PaintTabStripBackground(g, x, y, width, height, placement)
    End Sub
    End Class

     
  • Replied 8 September 2017, 1:15 pm EST

    Thanks..
    I will implement that.. and post back here if i have issues.
  • Replied 8 September 2017, 1:15 pm EST

    Hi Scott,

    I put that in a test project. It worked great.
    Would you happen to have a c# version of the code?

    Thanks,
    Paresh
  • Replied 8 September 2017, 1:15 pm EST

    Thanks.I called spread.refresh() and it worked.
    Is that what you meant by redrawing or did you mean some otherway?

  • Replied 8 September 2017, 1:15 pm EST

    Hello,


    Calling the Refresh method will cause all visible areas to repaint, so this will repaint the area. I did not know when the MessageBox was show and the message was updated. I wanted to make sure you call the renderer.PaintGrayArea method to repaint the gray area before the new text. The Refresh method will work.

Need extra support?

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

Learn More

Forum Channels