Customizing the table borders dialog

4 posts, 1 answers
  1. Lasse
    Lasse avatar
    10 posts
    Member since:
    Jul 2013

    Posted 18 Jun 2014 Link to this post

    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.
  2. Lasse
    Lasse avatar
    10 posts
    Member since:
    Jul 2013

    Posted 23 Jun 2014 Link to this post

    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);
    }
  3. UI for WPF is Visual Studio 2017 Ready
  4. Answer
    Petya
    Admin
    Petya avatar
    975 posts

    Posted 23 Jun 2014 Link to this post

    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.
     
  5. Lasse
    Lasse avatar
    10 posts
    Member since:
    Jul 2013

    Posted 23 Jun 2014 Link to this post

    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.
Back to Top