Telerik Forums
UI for WPF Forum
1 answer
75 views

Hi,

I need to add a DateField to a TableCell in a RichTextBox so that when a user clicks on the cell in the UI a calendar is displayed. 

I can see from the XAML that this is achieved by using the InsertSdtCommand with a CommandParameter of Date, how can a similar result be achieved from within the code.

Thank you.

 

 

Dimitar
Telerik team
 answered on 17 Sep 2024
1 answer
64 views

Hi,

When I update a table cell in a richtextbox the table is locked and I am unable to edit the table  in the UI. The change to the table cell is not shown in the

UI If I then close the current document and re-open it its fine and I can see the change made to the table cell, or if I make a change to a paragraph above the table from within the UI the change to the cell is shown, and the table is unlocked. 


        public void SetTemplateFromElement(string tagValue, string newValue)
        {
            try
            {
//                RadDocument document = doc_text.Document;
                var table = doc_text.Document.EnumerateChildrenOfType<Table>().Where(x => x.Tag == tagValue).FirstOrDefault();
                if (table != null)
                {

                    switch (tagValue)
                    {
                        case "1000":
                            var row = table.EnumerateChildrenOfType<TableRow>().FirstOrDefault();
                            var cell = row.Cells.ToList()[1];
                            cell.Blocks.Clear();
                            Paragraph p = new Paragraph();
                            Span s = new Span();
                            s.FontWeight = FontWeights.Bold;
                            s.FontFamily = new FontFamily(CGlobals.docu_default_font);
                            s.FontSize = Unit.PointToDip(CGlobals.docu_default_font_size);
                            s.Text = newValue; ;
                            p.Inlines.Add(s);
                            cell.Blocks.Add(p);
                            break;
                        case "4000":
                            break;
                    }

                    //                    doc_text.Document = document;
                    doc_text.UpdateLayout();
                    SaveContent(strCurrentDoc);
                }
            }
            catch { }

        }

Can someone please advise.

Dimitar
Telerik team
 answered on 09 Sep 2024
1 answer
60 views

Hi,

I need to add bullets to a TableCell from code. I have tried cell.Blocks.Add(bullets) where bullets is a DocumentList but I am getting 'cannot convert from DocumentList to Block.

Code snippet:


                            DocumentList bullets = new DocumentList(DefaultListStyles.Bulleted, document);
                            p1 = new Paragraph();
                            s1 = new Span();
                            cell1.Background = Color.FromRgb(255, 255, 255);
                            cell1.PreferredWidth = w1;
                            cell1.Padding = new Telerik.Windows.Documents.Layout.Padding(3, 6, 3, 6);
                            s1.FontFamily = new FontFamily(CGlobals.docu_default_font);
                            s1.FontSize = Unit.PointToDip(CGlobals.docu_default_font_size);
                            s1.Text = name;
                            p1.Inlines.Add(s1);
                            bullets.AddParagraph(p1);
                            cell1.Blocks.Add(bullets);

Thank you

Steve
Top achievements
Rank 2
Iron
Iron
Iron
 answered on 06 Sep 2024
0 answers
48 views

A couple of questions regarding DocumentVariableFields:

1. Is it possible to make a field read only, i.e. the field cannot be deleted from the UI.

I'm inserting the field into a table cell:

            RadDocumentEditor editor = new RadDocumentEditor(document);
            var cell = document.EnumerateChildrenOfType<TableCell>().ToList()[0];

            if (cell != null)
            {
                DocumentPosition position = new DocumentPosition(document);
                position.MoveToDocumentElementStart(cell.Blocks.First());
                document.CaretPosition.MoveToPosition(position);
                DocumentVariableField docVariable = new DocumentVariableField() { VariableName = "2000" };
                editor.InsertField(docVariable);
            }
            doc_text.Document = document;

            doc_text.Document.DocumentVariables["2000"] = "Date";
            //doc_text.Document.DocumentVariables["2002"] = " ";
            var field = doc_text.Document.EnumerateChildrenOfType<FieldRangeStart>().Where(x => x.Field.FieldTypeName == "DOCVARIABLE"
            && ((DocumentVariableField)x.Field).VariableName == "2000").FirstOrDefault();

            if (field != null)
            {
                doc_text.UpdateField(field);
            }

2. Is it possible to 'attach' a click event handler to a field, or a table cell?

 

Thank you

Steve
Top achievements
Rank 2
Iron
Iron
Iron
 updated question on 03 Sep 2024
1 answer
70 views

Hi,

We are creating a table which then gets inserted into a RichTextBox. We need to add a DocumentVariableField to one of the cells, can anyone please advise.


// The field which needs to be added o the table
            
doc_text.Document.DocumentVariables.Add("1001", addrName);
DocumentVariableField docVariable = new DocumentVariableField() { VariableName = "1001"  };
           
doc_text.InsertField(docVariable, FieldDisplayMode.Result);
            

RadDocument document = new RadDocument();
Section section = new Section();

TableWidthUnit w1 = new TableWidthUnit(100);
TableWidthUnit w2 = new TableWidthUnit(520);

Table table = new Table();
table.StyleName = RadDocumentDefaultStyles.DefaultTableGridStyleName;

TableRow row1 = new TableRow();
TableCell cell1 = new TableCell();
cell1.Background = Color.FromRgb(174, 255, 190);
cell1.PreferredWidth = w1;
cell1.Padding = new Telerik.Windows.Documents.Layout.Padding(3, 6, 3, 6);
Paragraph p1 = new Paragraph();
Span s1 = new Span();
s1.FontWeight = FontWeights.Bold;
s1.FontFamily = new FontFamily(CGlobals.docu_default_font);
s1.FontSize = Unit.PointToDip(CGlobals.docu_default_font_size);
s1.Text = "Name";
p1.Inlines.Add(s1);
cell1.Blocks.Add(p1);
row1.Cells.Add(cell1);

TableCell cell2 = new TableCell();
cell2.Background = Color.FromRgb(174, 255, 190);
cell2.PreferredWidth = w2;
cell2.Padding = new Telerik.Windows.Documents.Layout.Padding(3, 6, 3, 6);
Paragraph p2 = new Paragraph();
Span s2 = new Span();
s2.FontWeight = FontWeights.Bold;
s2.FontFamily = new FontFamily(CGlobals.docu_default_font);
s2.FontSize = Unit.PointToDip(CGlobals.docu_default_font_size);
            
s2.Text = addrName;  // We need to change this to the DocumentVariableField
p2.Inlines.Add(s2);
cell2.Blocks.Add(p2);
row1.Cells.Add(cell2);
table.Rows.Add(row1);

section.Blocks.Add(new Paragraph());
section.Blocks.Add(table);
section.Blocks.Add(new Paragraph());
document.Sections.Add(section);

doc_text.Document = document;

 

Many thanks

Dimitar
Telerik team
 answered on 26 Jul 2024
1 answer
95 views

Hi,

We are creating a table and adding it to a RichTextBox:


        public void AddAddress()
        {
            string addrName = string.Empty;
            string[] rowName = new string[] { "Job Title", "Employer", "Address", "Tel.", "Tel. Dir.", "Mobile", "Email", "Website", "Fax", "Details", "Address", "Tel.", "Mobile", "Email", "Details" };
            if(_selelement != null)
            {
                addrName = _selelement.GetAttribute("title");
            }
            SdtProperties sdtProperties = new SdtProperties(SdtType.RichText)
            {
                Alias = "AddressName",
                Lock = Lock.SdtContentLocked,
                ID = 1001,
            };
            RadDocument document = new RadDocument();
            Section section = new Section();

            TableWidthUnit w1 = new TableWidthUnit(100);
            TableWidthUnit w2 = new TableWidthUnit(520);

            Table table = new Table();
            table.StyleName = RadDocumentDefaultStyles.DefaultTableGridStyleName;

            TableRow row1 = new TableRow();
            TableCell cell1 = new TableCell();
            cell1.Background = Color.FromRgb(174, 255, 190);
            cell1.PreferredWidth = w1;
            cell1.Padding = new Telerik.Windows.Documents.Layout.Padding(3, 6, 3, 6);
            Paragraph p1 = new Paragraph();
            p1.Background = Color.FromRgb(174, 255, 190);
            Span s1 = new Span();
            s1.FontWeight = FontWeights.Bold;
            s1.FontFamily = new FontFamily(CGlobals.docu_default_font);
            s1.FontSize = Unit.PointToDip(CGlobals.docu_default_font_size);
            s1.Text = "Name";
            p1.Inlines.Add(s1);
            cell1.Blocks.Add(p1);
            row1.Cells.Add(cell1);

            TableCell cell2 = new TableCell();
            cell2.Background = Color.FromRgb(174, 255, 190);
            cell2.PreferredWidth = w2;
            cell2.Padding = new Telerik.Windows.Documents.Layout.Padding(3, 6, 3, 6);
            Paragraph p2 = new Paragraph();
            p2.Background = Color.FromRgb(174, 255, 190);
            Span s2 = new Span();
            s2.FontWeight = FontWeights.Bold;
            s2.FontFamily = new FontFamily(CGlobals.docu_default_font);
            s2.FontSize = Unit.PointToDip(CGlobals.docu_default_font_size);
            s2.Text = addrName;
            p2.Inlines.Add(s2);
            cell2.Blocks.Add(p2);
            row1.Cells.Add(cell2);
            table.Rows.Add(row1);

            int rowCount = 0;
            foreach(string rname in rowName)
            {
                rowCount++;
                row1 = new TableRow();
                cell1 = new TableCell();
                p1 = new Paragraph();
                if (rowCount < 11)
                {
                    cell1.Background = Color.FromRgb(255, 229, 153);
                    p1.Background = Color.FromRgb(255, 229, 153);
                }
                else
                {
                    cell1.Background = Color.FromRgb(196, 255, 255);
                    p1.Background = Color.FromRgb(196, 255, 255);
                }
                cell1.Padding = new Telerik.Windows.Documents.Layout.Padding(3, 6, 3, 6);
                s1 = new Span();
                s1.FontWeight = FontWeights.Bold;
                s1.FontFamily = new FontFamily(CGlobals.docu_default_font);
                s1.FontSize = Unit.PointToDip(CGlobals.docu_default_font_size);
                s1.Text = rname;
                p1.Inlines.Add(s1);
                cell1.Blocks.Add(p1);
                row1.Cells.Add(cell1);

                cell2 = new TableCell();
                cell2.Background = Color.FromRgb(255, 255, 255);
                cell2.Padding = new Telerik.Windows.Documents.Layout.Padding(3, 6, 3, 6);
                p2 = new Paragraph();
                s2 = new Span();
                s2.FontFamily = new FontFamily(CGlobals.docu_default_font);
                s2.FontSize = Unit.PointToDip(CGlobals.docu_default_font_size);
                s2.Text = " ";
                p2.Inlines.Add(s2);
                cell2.Blocks.Add(p2);
                row1.Cells.Add(cell2);
                table.Rows.Add(row1);
            }

            section.Blocks.Add(new Paragraph());
            section.Blocks.Add(table);
            section.Blocks.Add(new Paragraph());
            document.Sections.Add(section);

            doc_text.Document = document;   
        }

How can we add a Content Control with StdProperties to one of the table cells, similar to:

SdtProperties sdtProperties = new SdtProperties(SdtType.RichText) 
{ 
    Alias = "AliasName", 
    Lock = Lock.SdtContentLocked, 
}; 
doc_text.InsertStructuredDocumentTag(sdtProperties); 

Dimitar
Telerik team
 answered on 26 Jul 2024
0 answers
36 views
I have a docx file and it contains line numbers like the image below.



When I use the PdfFormatProvider to convert the docx to pdf the line numbers do not display on the PDF. However, if I manually open the document and save as a PDF they do.

Is there something I am missing here?
Patrick
Top achievements
Rank 1
 asked on 19 Jul 2024
0 answers
66 views

Hello,

I tried to make a word document viewer with richtextboxes. The structure is displayed correctly, except for the parts where there are text boxes or comboboxes.
Attached is an example of the display difference.
Any help would be greatly appreciated.

I'm using Q1 2024 version of controls.

Sergio
Top achievements
Rank 1
 asked on 05 Jul 2024
0 answers
61 views
I'd like to know if I can make it so tables and images always fill width of RichTextBox.

I have a RichTextBox control that is not very wide and I want text to wrap and not give them a horizontal scrollbar. I can't set an explicit width as this needs to be dynamic. Is there anyway that I can make it so that tables/ pictures are inline and always occupy the entire width?
Patrick
Top achievements
Rank 1
Iron
Iron
Iron
 asked on 03 Jul 2024
1 answer
69 views

Having an issue displaying images in a radRichTextBox. Below is my HTML. 

I have using an HTMLDataProvider to bind to a string that contains this HTML below.

The image does not display, all I get is this little box for the image.

The text all displays fine above it.

 


<head>
<link rel="stylesheet" href="../style.css" /> 
</head>
<p><strong>Section Header</strong></p>

<p><strong>Section Text</strong> This is my Description section</p>

<p><strong>Picture Title</strong></p>
<p><img src="../LocalFolderParent/Images/MyImage.png" alt="Figure 1 - Test 3" /></p>

Stenly
Telerik team
 answered on 28 Jun 2024
Narrow your results
Selected tags
Tags
+112 more
Top users last month
Jay
Top achievements
Rank 3
Iron
Iron
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
Radek
Top achievements
Rank 2
Iron
Iron
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Richard
Top achievements
Rank 4
Bronze
Bronze
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Jay
Top achievements
Rank 3
Iron
Iron
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
Radek
Top achievements
Rank 2
Iron
Iron
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Richard
Top achievements
Rank 4
Bronze
Bronze
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?