technofantasy

博客园 首页 新随笔 联系 订阅 管理
  22 Posts :: 16 Stories :: 64 Comments :: 1 Trackbacks
visual basic code:
Dim iPos As Long
Dim strInsert As String
Dim strRTF As String
Dim lStart As Long

'assumes that strInsert contains the RTF code that you want to insert
'
and that the current cursor position is where you want it selected
    With RichTextBox1
      
'mark the current insertion point with special characters
        .SelText = Chr(&H9D) & Chr(&H81)
      
'get the rtf text into our variable
        strRTF = .TextRTF
      
'insert our text at the insertion point
        strRTF = Replace(.TextRTF, "\'9d", strInsert)
        .TextRTF 
= strRTF
      
'now find the end of the insertion
        lStart = .Find(Chr(&H81))
      
'get rid of the other character
        strRTF = Replace(.TextRTF, "\'81""")
        .TextRTF 
= strRTF
      
'position the cursor after the insertion
        .SelStart = lStart
   
End With
posted on 2006-09-06 17:06 陈锐 阅读(314) 评论(0)  编辑 收藏 所属分类: RichTextBox技巧

标题  
姓名  
主页
Email (只有博主才能看到) 
验证码 *  看不清,换一张 [登录][注册]
内容(请不要发表任何与政治相关的内容)  
  登录  使用高级评论  新用户注册  返回页首  恢复上次提交