 |
| ADO.NET For discussion about ADO.NET.  Topics such as question regarding the System.Data namespace are appropriate.  Questions specific to a particular application should be posted in a forum specific to the application . |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the ADO.NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

October 16th, 2004, 05:05 AM
|
|
Registered User
|
|
Join Date: Oct 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
FILE HANDLING
HOW CAN WE READ A WORD DOCUMENT AND SHOW IT IN A TEXTBOX?
|
|

October 31st, 2004, 09:35 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 996
Thanks: 2
Thanked 11 Times in 11 Posts
|
|
I'd happy too, if anyone gives an idea!
Always:),
Hovik Melkomian.
|
|

November 4th, 2004, 04:40 PM
|
|
Friend of Wrox
|
|
Join Date: Jul 2004
Posts: 623
Thanks: 0
Thanked 1 Time in 1 Post
|
|
Hello,
Take a look at this example,
Code:
using System.Text;
using System.IO;
....
private void button1_Click(object sender, System.EventArgs e)
{
OpenFileDialog dlg = new OpenFileDialog();
dlg.Title = "Open text file" ;
dlg.InitialDirectory = @"c:\" ;
dlg.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*" ;
if(dlg.ShowDialog() == DialogResult.OK)
{
StreamReader sr = File.OpenText(dlg.FileName);
string s = sr.ReadLine();
StringBuilder sb = new StringBuilder();
while (s != null)
{
sb.Append(s);
s = sr.ReadLine();
}
sr.Close();
textBox1.Text = sb.ToString();
}
}
--------------------------------------------
Mehdi.:)
|
|

November 4th, 2004, 04:46 PM
|
|
Friend of Wrox
|
|
Join Date: Jul 2004
Posts: 623
Thanks: 0
Thanked 1 Time in 1 Post
|
|
very good link for working on TextBoxes,
http://www.syncfusion.com/FAQ/WinForms/FAQ_c94c.asp
--------------------------------------------
Mehdi.:)
|
|

November 5th, 2004, 02:03 AM
|
|
Friend of Wrox
|
|
Join Date: Feb 2004
Posts: 177
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi Mehdi62b I think you are telling about opening a txt document and what they need is opening a Word Document in .NET.
I have solution for that, the code below will open the Word Document file, reads text from it and display it on the textBox
Before writing the code add a refrence to the "Microsoft Word Object Library"
in the "COM" tab of Add Reference menu option
Code
****
object fileName = @"C:\test.DOC";
object readOnly = false;
object isVisible = true;
object missing = System.Reflection.Missing.Value; // To handle unecessary params
Word.ApplicationClass oWordApp = new Word.ApplicationClass();
Word.Document oWordDoc = oWordApp.Documents.Open(ref fileName, ref missing,ref readOnly, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref isVisible, ref missing,ref missing,ref missing, ref missing);
textBox1.Text = oWordDoc.Content.Text.ToString ();
Hope this helps :-)
It is not how much we do,
but how much love we put in the doing.
-Mother Theresa
|
|

November 5th, 2004, 04:26 AM
|
|
Friend of Wrox
|
|
Join Date: Jul 2004
Posts: 623
Thanks: 0
Thanked 1 Time in 1 Post
|
|
is there any much difference between DOC or TXT(for writing to TextBoxes!)?
both of them are Text files(like HTML,ASPX,...).
--------------------------------------------
Mehdi.:)
|
|

November 5th, 2004, 06:53 AM
|
|
Friend of Wrox
|
|
Join Date: Feb 2004
Posts: 177
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Yes there are lot of difference between an ordinary text files and doc files. txt files store only the text, but word can store text, images and other ole objects etc., Also its stores lot of formating information with the text.
It is not how much we do,
but how much love we put in the doing.
-Mother Theresa
|
|

November 5th, 2004, 07:35 AM
|
|
Friend of Wrox
|
|
Join Date: Jul 2004
Posts: 623
Thanks: 0
Thanked 1 Time in 1 Post
|
|
Ya,okay,
I dont know whether we can print the pics and formatting information within a TextBox?!
--------------------------------------------
Mehdi.:)
|
|

November 8th, 2004, 12:34 AM
|
|
Friend of Wrox
|
|
Join Date: Feb 2004
Posts: 177
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I don't think we can display images in text box, but some formatted text can be.
It is not how much we do,
but how much love we put in the doing.
-Mother Theresa
|
|
 |