ninja_aya 发表于 2014-11-10 17:08:00

询问两个功能是否可以实现

1、第一个功能是按照段落划分,将A文档中的部分段落拷贝到B文档中,要求文字和样式一致
目前想到两个方法,一个是for循环A文档中的段落,当这个段落符合拷贝要求时,调用textcontrol1.copy(),然后textcontrol2.paste()
但是这样写好像没什么用,复制拷贝没效果,请问代码需要怎么写?
第二个方法是我for循环A文档中的段落,然后textcontrol2.selection.text=段落.text,然后将段落的所有样式都复制到textcontrol2当前段落中。s1.Baseline = s2.Baseline;
            s1.Bold = s2.Bold;
            s1.FontName = s2.FontName;
            s1.FontSize = s2.FontSize;
            s1.ForeColor = s2.ForeColor;
            //s1.FormattingStyle = s2.FormattingStyle;
            s1.Italic = s2.Italic;
            s1.TextBackColor = s2.TextBackColor;
            s1.Underline = s2.Underline;
            s1.ParagraphFormat.AbsoluteLineSpacing = s2.ParagraphFormat.AbsoluteLineSpacing;
            s1.ParagraphFormat.Alignment = s2.ParagraphFormat.Alignment;
            s1.ParagraphFormat.BottomDistance = s2.ParagraphFormat.BottomDistance;
            s1.ParagraphFormat.KeepLinesTogether = s2.ParagraphFormat.KeepLinesTogether;
            s1.ParagraphFormat.KeepWithNext = s2.ParagraphFormat.KeepWithNext;
            s1.ParagraphFormat.LeftIndent = s2.ParagraphFormat.LeftIndent;
            s1.ParagraphFormat.LineSpacing = s2.ParagraphFormat.LineSpacing;
            s1.ParagraphFormat.PageBreakBefore = s2.ParagraphFormat.PageBreakBefore;
            s1.ParagraphFormat.RightIndent = s2.ParagraphFormat.RightIndent;
这个方法感觉代码看上去很繁琐,请问有什么好方法吗?要求效率比较高的

2.请问下你们有没有txtextcontrol网页版本的控件,要求能实现用户在网页上就能编辑.tx文件并保存到服务器。

Alice 发表于 2014-11-10 18:19:00

回复 1楼ninja_aya的帖子

请问你是不是使用的WinForm平台下的Tx Text Control?
1.这个问题我需要测试下才能给你准确的答复,还望理解。
2.根据技术平台的不同,TX Text Control 产品分为 .NET for Windows Forms、.NET Server for Windows Forms、.NET for WPF、.NET Server for WPF、ActiveX、ActiveX Server等六个产品。

ninja_aya 发表于 2014-11-10 20:09:00

那你说的这六个产品里面哪个能满足我第二个功能呢?

Alice 发表于 2014-11-11 10:28:00

回复 3楼ninja_aya的帖子

有两种:
使用Tx TextControl for Windows Forms,创建所见即所得的BS程序。把文档加载到网页,你可以参考下博客:
http://blog.gcpowertools.com.cn/post/2012/11/16/tx_win_WYSIWYG.aspx

使用.Net Server for ASP.NET,基于Html5的WebEditor的在线Demo:
http://txlabseu.cloudapp.net/simple/index.aspx#

ninja_aya 发表于 2014-11-12 10:34:00

请问下,那个copy和paste有实现吗?

Alice 发表于 2014-11-12 11:32:00

回复 5楼ninja_aya的帖子

textControl.Copy和textControl.Paste是指对Current选择进行复制和粘贴。
所以如果使用这个方法,需要先进行选择,然后在复制和粘贴:
举个例子来说,复制全部,比如:
txControl.Focus();
txControl.SelectAll();
txControl.Copy();
txControl.Select(0, 0);


如果你需要格式的复制粘贴,建议使用SaveToMemory 和LoadFromMemory 方法。 SaveToMemory 复制内容和格式到the memory。
再举个例子说明:

byte[] data;
data = TXTextControl1.SaveToMemory(3, false);
TXTextControl2.LoadFromMemory(data, 3, false);
页: [1]
查看完整版本: 询问两个功能是否可以实现