Lebans RTF2 - adding text with a button

  • Thread starter Thread starter matthias greier
  • Start date Start date
M

matthias greier

How can i add text to the RTF2.Memo without loosing the formatting?
I tried both:
--- Me.RTF20.Object.PlainText = Me.RTF20.Object.PlainText & Chr(13) &
---Chr(10) & Me!Liste0.Column(1, itm) & ": " & Chr(13) & Chr(10)
Formatting is lost

---Me.RTF20.Object.PlainText = Me.RTF20.Object.PlainText & Chr(13) &
--- Chr(10) & Me!Liste0.Column(1, itm) & ": " & Chr(13) & Chr(10)
Doesn't add anything.

Can i also add Text INTO the Text, like if I push a button, text should
be inserted where the coursor was.

thank you, matthiasAustria
 
I don't have Stephen's control installed on this machine, but I suspect the
issue is your use of the PlainText property is what's causing the formatting
to be lost.

What's the difference between your two examples supposed to be? They look
identical to me.
 
Hi Douglas!!
What's the difference between your two examples supposed to be? They look
identical to me.

The second one should have been:
So, I tried Plaintext, which sounds like loosing the format, and also
RTFText, but didn't bring this to work.

Thanks, Matthias
 
Matthias if you want to be an effective programmer/developer/power user you
need to learn how to search all of the resources available to you. In all of
my years programming, 99% of the issues I encounter have already been solved
by other people. You can save yourself a lot of time and effort simply by
learning how to search GoogleGroups and the MS Knowledge Base.

For your particular issue, do a GoogleGroups search on:
http://groups.google.ca/groups?hl=en&lr=&safe=off&num=10&q=lebans+rtf2+seltext&safe=off
lebans RTF2 SelText

If you need more basic instructions then GoogleGroups again on:
RTF SelText

The RTF control is like a normal TextBox control in regards to setting an
insertion point and then inserting Text.

I freely admit that there is not a good help file with my RTF control. I
simply have not found a basic RTF help file that I can supply a pointer to.
If you find one please let me know and I will post the URL on my site. If
you scroll down toward the bottom of the RTF2 Web page you will see a list
of all properties and methods. The relevant ones for your issue are:
SelLength As Long

Returns/sets the number of characters selected.

SelStart As Long

Returns/sets the starting point of text selected; indicates the position of
the insertion point if no text is selected.

Const SelTextRTF

Returns/sets the text (in .RTF format) in the current selection of a
RichTextBox control.

Const SelText

Returns/sets the string containing the currently selected text; consists of
a zero-length string if no characters are selected.



--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 
Thank you Stephen!


The only problem I still have is,

SelStart As Long

Thisone returns only the position of the Plaintext. How can I figure out,
how many signs there are before the start of the plaintext?

Or is there a method to get the position of the RtfText?

thanks!
 
Figured it out now, somehow .. :D

Copiing the text to insert into a hidden rtf2:
RTF2hidden.Object.PlainText = Me!txtABC.Text

Saving the current cursor position into a public variable:
Private Sub RTF21_LostFocus()
varCursPos = RTF21.SelStart
End Sub

Finally inserting into the RTF2:
RTF21.SelStart = varCursPos
RTF21.Object.SelTextRTF = RTF2hidden.Object.SelTextRTF


Thanks,
matthew
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top