Show Gridlines?

7 posts, 1 answers
  1. Charles
    Charles avatar
    41 posts
    Member since:
    Mar 2012

    Posted 09 Mar 2012 Link to this post

    Is there a "ShowGridlines" property I can't find? 

    If not, is there any way to show the bounds of table cells when there are no borders set?  I would assume I could implement this via a Custom UI Layer - if this is the only way, any pointers welcome!
  2. Answer
    Iva Toteva
    Admin
    Iva Toteva avatar
    1319 posts

    Posted 09 Mar 2012 Link to this post

    Hello Charles,

    There is no property ShowGridlines, but you are right that this effect can be achieved using a custom UI layer. Please find attached a demo illustrating how his can be done.

    Kind regards,
    Iva Toteva
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
  3. UI for WPF is Visual Studio 2017 Ready
  4. Charles
    Charles avatar
    41 posts
    Member since:
    Mar 2012

    Posted 09 Mar 2012 Link to this post

    Thanks - works perfectly!
  5. Edward
    Edward  avatar
    32 posts
    Member since:
    Jan 2008

    Posted 31 Jul 2012 Link to this post

    When i use this, it prints fine in HTML Print (the grid line isn't shown on print out), but in Silverlight native print the grid line is also printed.  Is there anyway to fix that?
  6. Clifford
    Clifford avatar
    25 posts
    Member since:
    Sep 2013

    Posted 04 Dec 2013 Link to this post

    Tired this solution, and the grid lines appeared on the printed output. Also, had to clear borders, which could not see in the first place, before the outline border showed by selecting gridlines none
  7. Edward
    Edward  avatar
    32 posts
    Member since:
    Jan 2008

    Posted 06 Dec 2013 Link to this post

    Add a variable/property called ShowGridLine somewhere.  Then in the CustomLayer class:

    public override void UpdateUIViewPortOverride(UILayerUpdateContext context)
           {
               // if the RadDocument is too wide or too high, running the below code will make browser freezing
               if (context.Presenter.Owner.GetType() == typeof(Telerik.Windows.Controls.RadRichTextBox))
               {
                   if (context.ViewPort.Width > 2000 || context.ViewPort.Height > 2000)
                       return;
               }
     
               if (ShowGridLine)
                   foreach (var box in context.GetVisibleLayoutBoxes<TableCellLayoutBox>())
                   {
                       if (this.AreBordersOfCellNone(box))
                       {
                           RectangleF rect = new RectangleF();
                           rect.X = box.ControlBoundingRectangle.Left;
                           rect.Width = box.ControlBoundingRectangle.Right - rect.X;
     
                           rect.Y = box.ControlBoundingRectangle.Top;
                           rect.Height = box.ControlBoundingRectangle.Bottom - rect.Y;
     
                           this.AddRectangle(rect);
                       }
                   }
           }


    Then when you print, set ShowGridLine = false.  Handle the PrintCompleted event and set it back to true there.
  8. Rasmus
    Rasmus avatar
    1 posts
    Member since:
    Feb 2013

    Posted 05 Dec 2014 Link to this post

    Hi, 

    We have tried to use this gridlayer suggestion in our solution. However, It performs really badly with even a table of moderate size ( 10x50). Textediting and scrolling become unbearably sluggish.

    I have tried to do a Dispatcher.BeginInvok(...) around the updating of the grid layout, but that doesnt seem to work very well. Setting it with a too low priority creates a bad user experience with flickering layer, and too high priority destroys performance.

    Do you have an alternate solution that work with a table of 10x50 cells (which doesnt seem like a lot), or suggestions to how make the proposed solution scale?
Back to Top
UI for WPF is Visual Studio 2017 Ready