AlexBB


I set up a RichTextBox and show content of memo files from VFP DB tables. Over at VFP which refuses to comply with Vista I had a control that gave me a chance to manipulate fonts and set colors to parts of the text if I wanted.

I am wondering how I shall do it in here Shall I use FontDialog for this

Also, I've been thinking of using a speller in that VFP Form setup but never got around to attach one. Is there a way to attach a speller to the RichTextBox

Thanks.





Re: RTF property

AlexBB


Also, an additional complication I forgot to mention is that VS2005 does not recognize the VFP Rtf format. It says: format is invalid. So, I use .Text = memoFile; where string memoFile is the content of my memo files in VFP.

Any thoughts as to how I should handle it Is there any way around it

Thanks.







Re: RTF property

AlexBB

OK, this is a continuation of this weird monologue.

I am trying to resolve the issue with my richTextBox.Rtf property. When I read my VFP9 memo fields in OleDbDataReader they are read as string type. In the object browser in Vs2005 these memo fields are exposed as OleDbType.Char. So, I get a string type variable and I can use it to display the content of my old VFP 9 memo fields in .NET C# app but I cannot use Rtf property, since I get an error. I am forced to use Text property. The content is displayed but with all formatting characters. I can read the texts but the formatting strings of characters obviously interfere.

Thus I started thinking about using DataBinding property to richTextBox. Using of it requires a DataSource object . I figured I can get one if I use a DataAdapter but it is very inconvenient for many practical reasons. I use a OleDbDataReader and endup with a string variable.

I guess it is time to formulate some questions.

I can create binary (blob) fields in VFP dataTables and copy the memo fields in there. I can then read them as OleDbType.Binary and try to create an object in C# and assign this binary field to it. Does it make sense

Will is be sufficient to do the databinding without assinging anything to Rft to have contents displayed

It appears Rtf property expects a string but a special string Is it true

I may have more questions later.

Thanks.







Re: RTF property

AlexBB

OK, this is a new problem. I expect that Cetin may crack this one easily. I posted on this issue in Windows Forms General but so far nobody touched it.

http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=2236535&SiteID=1&mode=1

In short I am trying to read my VFP memo fields in .NET but encountering a problem. I am trying to read them into RichTexTBox.Rtf property and I am getting an error that the string is not of correct format. I can read them into RichTextBox.Text property but all formatting characters are displayed.

I loaded those fields in VFP from my OLE bound control whose name I do not quite remember now, I think it is also RichTextBox. It has worked quite well in XP but now it is a different era. Fox just expired in Vista on me.

I do have a question. What if I convert my memo fields with type memo into either memo binary or binary or varbinary or whatever and try to read the latter into the control in .NET using DataBinding property in there. Will it work

Is is possible to convert memo fields into blob's Is it gonna work

Thanks.






Re: RTF property

CetinBasoz

Alex,

For RTF code datatype is char and stored in memo. You read that into correct property but probably your source is really not an RTF.

VFP comes with a sample table in samples\Solution\Ole folder. Table name is rtf with a single memo field named "source" holding RTF text.

-Create a windows form

-Add bindingsource and navigator as you would do usually

-Drop a Richtextbox control on form

-Bind to Rtf property. ie:

this.richTextBox1.DataBindings.Add(new System.Windows.Forms.Binding("Rtf", this.rtfBindingSource, "source", true));





Re: RTF property

AlexBB

CetinBasoz wrote:

Alex,

For RTF code datatype is char and stored in memo. You read that into correct property but probably your source is really not an RTF.

VFP comes with a sample table in samples\Solution\Ole folder. Table name is rtf with a single memo field named "source" holding RTF text.

-Create a windows form

-Add bindingsource and navigator as you would do usually

-Drop a Richtextbox control on form

-Bind to Rtf property. ie:

this.richTextBox1.DataBindings.Add(new System.Windows.Forms.Binding("Rtf", this.rtfBindingSource, "source", true));

Thank you, Cetin.

I think my source is in fact Rtf, I mean some memo field values are Rft formatted but others (some earlier rows in the same tables, historically) are plain text. I think it should not affect the databinding, should it

The reason I am pretty sure that the source (memo field) is rtf is the fact that I can still open them (in XP only) and see all my formatting displayed: some words are highlighted in red, other blue, bold face, etc. Also when I take this memoi field into .NET and assign it as a string to .RichTextBox.Text property I see all those crazy formatting characters which I do not want to comprehend, however, they are there for sure.

I will try what you are suggesting. Makes a lot of sense. Thank you. Will report back as well.

So, as I understand, all those plans to convert memo type to binary are just delusions, aren't they

PS.

As an afterthought, I think using the binding source the way you are suggesting will tie my code in knots. I do not want any table to be bound to the app. It is what I am trying to avoid. I may create a local object and copy the memo field content in there.

The reason for that is that I am always using just one memo field at a time. If I want to review another one, I can easily just abandon this internal object, it is GC'ed, that's it. Binding a table to the DataSource property will preclude many other operations to be performed. In VFP (under XP) I could do it, here is will increase the search times measureably.

Thanks.






Re: RTF property

CetinBasoz

You don't need to bind. You can simply store it in a string variable and assign rtf to string. Rtf itself is plain text.





Re: RTF property

AlexBB

CetinBasoz wrote:
You don't need to bind. You can simply store it in a string variable and assign rtf to string. Rtf itself is plain text.

That's precisely what I did the time around and I got an error that the string format was invalid.






Re: RTF property

CetinBasoz

Alex,

Provide correct format.

You can test if it's correct:

Copy the text and paste in a text file. Save as .rtf. Dblclick the file (probably you have office installed and default rtf handler program is word).

Also you can check it against RTF specification.