hi ,
i made a little RtfEncapsulator. Its a class thats called RichText ,
it has an RtfElementCollection which takes any class that exposes the
IRtfElement interface.
I managed to make an RtfTextElement which works really well.
So to add text this has to be done:
Code:
RichText richText = new RichText();
richText.ColorTable.Add(new RtfColor(Color.BlueViolet));
richText.FontTable.Add(new RtfFont(Font));
RtfTextElement txt = new RtfTextElement("Hello??");
txt.IsNewPara = true;
txt.Color = richText.ColorTable[0];
txt.Font = richText.FontTable[0];
txt.Alignment = TextAlignment.Centered;
richText.Elements.Add(txt);
But my table element does'nt work very well!
Code:
RtfTableElement table = new RtfTableElement();
table.ColumnCount = 3;
RtfTableRow row = new RtfTableRow();
row.Add(txt); row.Add(new RtfTextElement("Col2"));
row.Add(new RtfTextElement("Col3"));
table.Rows.Add(row);
richText.Elements.Add(table);
for one , i just make all the columns 1 inch wide.I want to be able to
set/get *pixel values* for _each_ column , to do that i need DPI to
calculate it , and i need an instance of the graphic class. I planned
to make a internal property for that , but there no generic way to
handle this!??
Also , it seems the .NET RichTextBox does'nt wrap a sentance in a
table cell! Does anyone know the control for that!?? Word and Wordpad
are do it fine.
Heres the source:
http://gidsfiles.googlepages.com/RichTextCore.cs
http://gidsfiles.googlepages.com/RichTextElements.cs
Thanks
Gideon