-
November 23rd, 2010, 06:49 AM
#1
Pass data from a rich text field in ms access database to a richtextbox control
Hi
I have a simple MS Access database with some rich text fields. I have been trying to
bind some RichTextBox controls in my form to these fields. When I used the following c# code blcok:
Code:
Binding bd = new Binding("Text", ds, "Words.meaning", true);
tbDesc.DataBindings.Add(bd);
ds= my DataSet
Words= my Table
meaning=A richtext field in my table
when I executed this code, I got a non rich text tagged with rtf lables:
<div>text</div> which I do not need.
I want exactly the rich text to be displayed on the RichTextBox. So I binded the "Rtf" property of my richtextbox to the dataset:
Code:
Binding bd = new Binding("Rtf", ds, "Words.meaning", true);
tbDesc.DataBindings.Add(bd);
But I got nothing on the RichTextBox.
I don't know why it is not showing anything!
Can you suggest a way to bind a richtextbox and get the proper results?
Thanks in advance
-
November 23rd, 2010, 08:43 AM
#2
Re: Pass data from a rich text field in ms access database to a richtextbox control
Huh... interesting... the only difference between what you've done and what I've done in the past is that I'm used to binding to a specific object (as opposed to a dataset). Also, I pass False for the formatting parameter... try changing that and see if it makes a difference.
Umm..... I'm re-reading your post... the snip you posted: <div>text</div> Ummm... that's HTML, not RTF. They're not compatible. Can you post what your raw data looks like? (like when you bound it to the Text property .... what was the result?)
-tg
-
November 23rd, 2010, 12:56 PM
#3
Re: Pass data from a rich text field in ms access database to a richtextbox control
Thanks for your response.
I tried to change the formatting parameter from true to false and then I got Argument Exception error.
And about my raw data I just simply typed the word "text" in MS Access database.
but executing the first code (in first post of the thread) I got <div>text</div> on my richTextBox which is indeed in html format!
I don't know how to fix this.
-
November 23rd, 2010, 03:39 PM
#4
Re: Pass data from a rich text field in ms access database to a richtextbox control
OK, the reason binding to the Rtf property doesn't work... it's not RTF. It's text. Straight up. The fact that it's HTML is actually irrelevant, since it is still just text. As such, you'll need to use a different component that can take HTML and mark it up. The only ones I can think of off the top of my head are designed to work on web sites, not in a WinForm.
Now, if you simply typed "text" into the database field, and it's coming out <div>text</div>" then there's something in the middle between you and your database that is adding the div tags.
In short what you need to be looking for is a WinForms-based HTML editor component of some kind.
See if any of these are any help: http://www.google.com/search?q=winforms+html+editor
-tg
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|