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

Customizing the table borders dialog

3 Answers 46 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Lasse
Top achievements
Rank 1
Lasse asked on 18 Jun 2014, 11:26 AM
Is it possible to customize the table borders dialog in any
way? I'd like to use the dialog but limit the number of colours and types of
borders the user should be able to set.

3 Answers, 1 is accepted

Sort by
0
Lasse
Top achievements
Rank 1
answered on 23 Jun 2014, 09:44 AM
In case others have the same requirement as I did; I manged to find a "hack" using reflection. It's definitely not pretty, but it works...

var tableBordersDialog = (TableBordersDialog as TableBordersDialog);
if (tableBordersDialog == null) return;
 
var tableBordersProperties = tableBordersDialog.FindName("tableBordersControl") as TableBordersProperties;
if (tableBordersProperties == null) return;
 
var tableBordersSelector = tableBordersProperties.FindName("borderSelector") as TableBorderSelector;
if (tableBordersSelector == null) return;
 
FieldInfo fieldInfo = typeof(TableBorderSelector).GetField("bordersList", BindingFlags.Instance | BindingFlags.NonPublic);
if (fieldInfo == null) return;
 
var field = fieldInfo.GetValue(tableBordersSelector);
 
var borderList = field as IList;
if (borderList == null) return;
 
if (borderList.Count == 9) //Initially the list has 9 known items.
{
    //We need to remove the 3 not applicable
    borderList.RemoveAt(5); //DotDotDash
    borderList.RemoveAt(4); //DotDash
    borderList.RemoveAt(2); //DashSmallCap
    fieldInfo.SetValue(tableBordersSelector, field);
}
0
Accepted
Petya
Telerik team
answered on 23 Jun 2014, 10:43 AM
Hello Lasse,

All dialogs that come out of the box with RadRichTextBox are fully customizable. You can create a custom dialog and with the help of MEF force the control to load it instead of the default one. The attached application shows how this can be achieved. The custom dialog in it contains the code of the default one, so you can customize it to fit your needs. 

I hope this helps.

Regards,
Petya
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
0
Lasse
Top achievements
Rank 1
answered on 23 Jun 2014, 05:18 PM
Thank you for the reply. I would rather not have to maintain my own version of the build in dialog. So will stick with the solution using reflection until I have trouble with it.
Tags
RichTextBox
Asked by
Lasse
Top achievements
Rank 1
Answers by
Lasse
Top achievements
Rank 1
Petya
Telerik team
Share this question
or