Hello !
With c# , I want to write to a text file in a specific font and color.
Any ideas ?
Thanks... 14 16885
Niron,
What do you want to write the file on. If you use Graphics object to draw
each line then any of the DrawString overloads accept font and brush object.
If you want show in a textbox control then you can use RichTextBox control
where you can change the color and the font for different parts of the text.
--
Stoitcho Goutsev (100)
"Niron kag" <Niron ka*@discussions.microsoft.com> wrote in message
news:6C**********************************@microsof t.com... Hello ! With c# , I want to write to a text file in a specific font and color.
Any ideas ?
Thanks...
Well, a "text" file *has* neither font nor colo[u]r; so - you need to be
more specific: what file format do you mean; HTML would be simple,
presumably using <FONT> or CSS attributes; RTF would be achievable by using
the RichTextBox control; set the text, then manipulate the font etc
(something like below):
// (assumes richTextBox1 declared and assigned at this point)
richTextBox1.Text = "Some Text";
richTextBox1.SelectAll();
richTextBox1.SelectionFont = new Font("Times New Roman", 20);
richTextBox1.SelectionColor = Color.Aquamarine;
richTextBox1.SaveFile("C:\\My.rtf");
Hope this helps,
Marc
"Niron kag" <Niron ka*@discussions.microsoft.com> wrote in message
news:6C**********************************@microsof t.com... Hello ! With c# , I want to write to a text file in a specific font and color.
Any ideas ?
Thanks...
Text files (if you mean files with a .txt extension that open in Notepad for
example) don't have such things.
Although the version of Notepad in W2K and XP can support different
fonts/colours etc, this is a local display option on the computer, *not*
formatting information held in the file.
Perhaps you want to use .rtf files? These allow font info and so on. Or
perhaps .html as others suggest.
Depends on why you are trying to achieve this...
James.
Thank U Marc Gravell,
I wanted to wrote to a file with suffix ".txt" , and I understand I can not.
I need to create ".rtf" file ?!
"Marc Gravell" wrote: Well, a "text" file *has* neither font nor colo[u]r; so - you need to be more specific: what file format do you mean; HTML would be simple, presumably using <FONT> or CSS attributes; RTF would be achievable by using the RichTextBox control; set the text, then manipulate the font etc (something like below):
// (assumes richTextBox1 declared and assigned at this point) richTextBox1.Text = "Some Text"; richTextBox1.SelectAll(); richTextBox1.SelectionFont = new Font("Times New Roman", 20); richTextBox1.SelectionColor = Color.Aquamarine; richTextBox1.SaveFile("C:\\My.rtf");
Hope this helps,
Marc
"Niron kag" <Niron ka*@discussions.microsoft.com> wrote in message
news:6C**********************************@microsof t.com... With c# , I want to write to a text file in a specific font and color.
As others have told you, font and colour are "rich text" attributes - text
files are "plain text", so don't support such things.
Why do the files need to be created?
What do you intend doing with them?
Have you maybe considered PDF?
james ,
How do I create a file with suffix of "rtf" , can U explain it? (Or give me
link)?
Are the function to "write" and "read" from the ".rtf" file different from
the function of ".txt" file ?
Thank U!
"james" wrote: "Niron kag" <Niron ka*@discussions.microsoft.com> wrote in message news:6C**********************************@microsof t.com... Hello ! With c# , I want to write to a text file in a specific font and color.
Any ideas ?
Thanks...
Text files (if you mean files with a .txt extension that open in Notepad for example) don't have such things.
Although the version of Notepad in W2K and XP can support different fonts/colours etc, this is a local display option on the computer, *not* formatting information held in the file.
Perhaps you want to use .rtf files? These allow font info and so on. Or perhaps .html as others suggest.
Depends on why you are trying to achieve this... James.
RTF would be a solution, yes; whether it is the /right/ solution depends on
what you want to do with it. Plenty of others exist - with HTML and RTF
probably the two most common. HTML is more portable (e.g. to other OSes /
platforms) and is easier to read in its native form.
So yes, you need to write in some known format. RTF may suffice - but you
need to figure that out for sure.
Marc
Mark Rae ,
this file intend to give indication about success or failure of some
operations.
So I want to create a file for the user - that will be easy to read!
Any ideas?
"Mark Rae" wrote: "Niron kag" <Niron ka*@discussions.microsoft.com> wrote in message news:6C**********************************@microsof t.com...
With c# , I want to write to a text file in a specific font and color.
As others have told you, font and colour are "rich text" attributes - text files are "plain text", so don't support such things.
Why do the files need to be created?
What do you intend doing with them?
Have you maybe considered PDF?
Niron kag <Ni******@discussions.microsoft.com> wrote: this file intend to give indication about success or failure of some operations. So I want to create a file for the user - that will be easy to read! Any ideas?
Create a HTML file with a .HTML extension. It's easy if you simply use
<font> etc. attributes. Text files (.txt) are just sequences of
characters, they can contain no intrinsic color information.
-- Barry
"Niron kag" <Ni******@discussions.microsoft.com> wrote in message
news:FD**********************************@microsof t.com... this file intend to give indication about success or failure of some operations. So I want to create a file for the user - that will be easy to read! Any ideas?
Why can't they just view the details on screen? Why do you need to create a
file?
"Niron kag" <Ni******@discussions.microsoft.com> wrote in message
news:EC**********************************@microsof t.com... james , How do I create a file with suffix of "rtf" , can U explain it? (Or give me link)? Are the function to "write" and "read" from the ".rtf" file different from the function of ".txt" file ?
Thank U!
I'm afraid I don't know - I'm fairly new to C# myself.
But the link that Mark gave you should help you out with a few examples!
James.
Mark,
The reason I use file is I want to save all the indications about previous
operations.
Not only per current opration.
shai,
"Mark Rae" wrote: "Niron kag" <Ni******@discussions.microsoft.com> wrote in message news:FD**********************************@microsof t.com...
this file intend to give indication about success or failure of some operations. So I want to create a file for the user - that will be easy to read! Any ideas?
Why can't they just view the details on screen? Why do you need to create a file?
"Niron kag" <Ni******@discussions.microsoft.com> wrote in message
news:1F**********************************@microsof t.com... The reason I use file is I want to save all the indications about previous operations. Not only per current opration.
Hmm - maybe some sort of database is in order, then... :-) This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Google Mike |
last post by:
I have PHP version 4.2.2 that ships with RH9. I want to have it write
to a file like this:
function WriteLog($sLogFile, $sMsg) {
if (substr($sLogFile,1,1) != '/') {
$sLogFile =...
|
by: Gurk |
last post by:
hallow all
i'm using a common dialog to save data into a text file.
for so far i have this, but can someone give me a simpe exaple what i have
to do after the line Open cdl.FileName For Output...
|
by: Kevin Ingram |
last post by:
Ok, this is probably a silly question but I just keep hitting a brick wall
here.
I usually develop my sites entirely in ASP and use a database for data
storage, works great for me. I also...
|
by: WebSim via .NET 247 |
last post by:
Hi,
I want to read a text file, and then write it into dataset. Is it possible?
or Is there any solution that read text file into DB?
-----------------------
Posted by a user from .NET 247...
|
by: crjunk |
last post by:
I have a few text files out on our server that are being created dynamically
by an existing ASP web page. I'd like to write a small ASP.NET web form that
will allow users to view these text files...
|
by: GMK |
last post by:
Dear all
in my asp.net application i have a text file that is installed with my
application on the server.
this text file is filled with data through a web interface in my
application.
i need to...
|
by: Brad Sanders |
last post by:
Hello All,
Thanks to Richard's answer to my last post I understand
now what I have to do, but..
How do I put a Line Feed or a Form Feed into a text file?
Looking throught the .net help it...
|
by: musawer |
last post by:
Can Someone give a good link for C# Winform DataGrid Text Style Formating (Font,Color,Size etc)... Quick reply will be highly appreciated...
Thanks...
|
by: mainul |
last post by:
Hi guys i can write text file and also can read it. below are the codes.
<?PHP
//write to a file
$body_content="This is my content"; // Store some text to enter inside the file...
|
by: Pete Martinez |
last post by:
Greetings, I need a simple method using ActiveXobject in javascript to write a text file from the local drive to my webserver. I found a method on a previous thread that copies a file from the...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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,...
|
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...
|
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,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
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,...
|
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...
| |