hr5204562 发表于 2013-8-21 09:14:00

回复 10楼dof的帖子

你的意思是TextFrame 只能加载它本身? 我从外部不能传输TextFrame二进制数据吗? 因为从外部是能加载文本的,二进制不行,这个应该是有问题的吧,而且它提供了加载二进制数据的函数

hr5204562 发表于 2013-8-21 09:23:00

Demo中如果去掉frame.Selection.Save(out a, TXTextControl.BinaryStreamType.InternalUnicodeFormat);也加载不出来数据啊,我的意思这个从外部加载,并非从他本身去读取


TXTextControl.TextFrame frame = textControl1.TextFrames.GetItem(1000);

            frame.Activate();
            byte[] a = System.Text.Encoding.Default.GetBytes("123456");
            //frame.Selection.Save(out a, TXTextControl.BinaryStreamType.InternalUnicodeFormat);
            frame.Selection.Load(a, TXTextControl.BinaryStreamType.InternalUnicodeFormat);
            //frame.Selection.Load("测试文本", TXTextControl.StringStreamType.PlainText);

ZenosZeng 发表于 2013-8-21 16:10:00

请看以下代码:
    private void 加载二进制数据ToolStripMenuItem_Click(object sender, EventArgs e)
    {
      TXTextControl.TextFrame frame = textControl1.TextFrames.GetItem(1000);
      frame.Activate();

      // 读取外部TX文件
      int offset = 0;
      Stream oStream = File.OpenRead("Test1.tx");
      byte[] arrBytes = new byte;

      while (offset < arrBytes.LongLength)
      {
            offset += oStream.Read(arrBytes, offset, arrBytes.Length - offset);
      }

      // 加载到TX中
      frame.Selection.Load(arrBytes, TXTextControl.BinaryStreamType.InternalUnicodeFormat);
    }
页: 1 [2]
查看完整版本: TextFrame 问题