This is a migrated thread and some comments may be shown as answers.

Show Gridlines?

6 Answers 163 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Charles
Top achievements
Rank 1
Charles asked on 09 Mar 2012, 12:13 PM
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!

6 Answers, 1 is accepted

Sort by
0
Accepted
Iva Toteva
Telerik team
answered on 09 Mar 2012, 12:22 PM
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 >>
0
Charles
Top achievements
Rank 1
answered on 09 Mar 2012, 12:36 PM
Thanks - works perfectly!
0
Edward
Top achievements
Rank 1
answered on 31 Jul 2012, 07:15 PM
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?
0
Clifford
Top achievements
Rank 1
answered on 05 Dec 2013, 01:42 AM
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
0
Edward
Top achievements
Rank 1
answered on 06 Dec 2013, 07:00 PM
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.
0
Rasmus
Top achievements
Rank 1
answered on 05 Dec 2014, 01:44 PM
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?
Tags
RichTextBox
Asked by
Charles
Top achievements
Rank 1
Answers by
Iva Toteva
Telerik team
Charles
Top achievements
Rank 1
Edward
Top achievements
Rank 1
Clifford
Top achievements
Rank 1
Rasmus
Top achievements
Rank 1
Share this question
or