473,508 Members | 2,460 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

RichTextControl Rtf property

I have an application that simply reads the text in a RichTextBox control, and stores the text into the database. I want to use the plain RichTextBox control and not a database rtf control.

When I read the Rtf property it returns the text combined with rft codes, e.g.:
"{\\rtf1 ....... \r\0"

I then store this text in my Access database via an OdbcCommand. When I read the text back from the database, the returned text is @-quoted as follows:
@"{\\rtf1 ....... \r\0"

When I try to set the RichTextControl Rtf property with the value from the database an exception is thrown.

It would appear that the Rtf property cannot accept @-quoted values (e.g. a value of

@"This is a test"

will cause an error.

How can I work around this problem while still using the RichTextControl in the scheme above.

Nov 22 '05 #1
2 2632
Hello,

I work with Jet4.0 Databases all the time and use RichTextBoxes Often to retrieve RTF data from fields inside the database.

I have never run into the problem you are expaining about having a "@" at the beginning of the stored data.

How are you retrieving the data into the RichTextBox. Here are some examples that work for me.

Example 1,

Create A Dataset and bind the data to the rtf property of the RichTextBox

RichTextBox1.DataBindings.Add("RTF", ADataset, "TableName.ColumnName")

Example 2.

Create A Dataset and Fill the RichTextBox from a DataRow

Dim ADataRow as DataRow = ADataset.Tables("TableName").Rows(0)

RichTextBox1.RTF = ADataRow("ColumnName")

Example 3.

Create A CommandObject and Fill the RichTextBox from the object

Dim ACommand as new Oledb.Command = AConnection.CreateCommand

ACommand.CommandText = "Select * FROM TableName WHERE ID = 1"

AConnection.Open

RichTextBox1.RTF = ACommand.ExecuteScalar

AConnection.Close

Hope this helps,

Chuck

Maybe I am misunderstanding your question. Are you trying to add a "@" before the text in the RTF Box?
If so try this:

If the font and RTF is always going to be the same, you can add a "@" into the RTF by parsing the string and inserting a character into it after the RTF Header.

Dim AString as string = "{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttb l{\f0\fswiss\fprq2\fcharset0 Arial;}}\viewkind4\uc1\pard\f0\fs24 The remainder Of The Text Goes Here \par}"

AString = AString.Insert(114, "@")
RichTextBox1.Rtf = AString

The Result =

{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl {\f0\fswiss\fprq2\fcharset0 Arial;}}\viewkind4\uc1\pard\f0\fs24 @ The remainder Of The Text Goes Here \par}"
Nov 22 '05 #2
Hello,

I am glad that what was sent you to originally worked for you.
Consider the Following:
Dim InsertCommand As New OleDb.OleDbCommand()

InsertCommand.Connection = AConnection

NOTE: EVERY COLUMN INSIDE THE DATABASE MUST BE ACCOUNTED FOR IN THE INSERT
COMMAND

AnInsertString = "INSERT INTO MyTable VALUES (?,?);"

InsertCommand.CommandText = AnInsertString

InsertCommand.Parameters.Add("@ID", Data.OleDb.OleDbType.WChar)
InsertCommand.Parameters(0).Value = ID.Text

InsertCommand.Parameters.Add("@MyRTF",
Data.OleDb.OleDbType.WChar)
InsertCommand.Parameters(1).Value = RichTextBox.RTF

Try
AConnection.Open()
InsertCommand.ExecuteNonQuery()
AConnection.Close()
InsertCommand.Dispose()
Catch AnError As OleDb.OleDbException
AConnection.Close()
InsertCommand.Dispose()
End Try
Chuck
Nov 22 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
430
by: oneworld | last post by:
I have an application that simply reads the text in a RichTextBox control, and stores the text into the database. I want to use the plain RichTextBox control and not a database rtf control. When...
3
2462
by: Johnny M | last post by:
using Access 2003 Pardon the subject line, but I don't have a better word for this strange behavior (or behavior I don't understand!!!) I have a class module named DepreciationFactor. One of...
7
2600
by: MP | last post by:
Hello, I am trying to write a class that will expose some properties. One of the property is extracted from a SQL database and can be NULL or some integer value. Is there a elegant way of...
3
5139
by: MattC | last post by:
Hi, I found this code somewhere on the net and need to make some alterations. public class GenericSorter : IComparer { String sortProperty; bool sortOrder; public GenericSorter(String...
2
1746
by: Edward Diener | last post by:
How does one specify in a component that a property is a pointer to another component ? How is this different from a property that is actually an embedded component ? Finally how is one notified in...
0
5545
by: Brian Young | last post by:
Hi all. I'm using the Property Grid control in a control to manage a windows service we have developed here. The windows service runs a set of other jobs that need to be managed. The control...
3
6718
by: Marty McFly | last post by:
Hello, I have a control class that inherits from System.Web.UI.WebControls.Button. When I drag this control from the "My User Controls" tab in the toolbox onto the form, I want it to reflect the...
15
2024
by: Lauren Wilson | last post by:
Owning your ideas: An essential tool for freedom By Daniel Son Thinking about going into business? Have an idea that you think will change the world? What if you were told that there was no way...
1
1346
by: cday119 | last post by:
I have a Class with about 10 properties. All properties return right except for one. It is real annoying and I can't see why its not working. Maybe someone else can see something. It is the...
6
1580
by: =?Utf-8?B?UVNJRGV2ZWxvcGVy?= | last post by:
I am using a RichTextControl (C# VS2005 .NET 2.0) and allowing users to change the font and color of what ever they select. The problem I am having is that when I select a second set of character...
0
7231
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7133
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7336
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7405
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
5643
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5059
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3198
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1568
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
435
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.