Click here to Skip to main content
15,905,971 members
Home / Discussions / C#
   

C#

 
GeneralRe: How to programmatically change text to underlined style in RichTextBox? Pin
mav.northwind5-Apr-08 4:21
mav.northwind5-Apr-08 4:21 
GeneralRe: How to programmatically change text to underlined style in RichTextBox? Pin
SeeBees8-Apr-08 22:27
SeeBees8-Apr-08 22:27 
QuestionDatagrid parameter Pin
Gego Levente4-Apr-08 4:05
Gego Levente4-Apr-08 4:05 
GeneralRe: Datagrid parameter Pin
Rick van Woudenberg4-Apr-08 4:40
Rick van Woudenberg4-Apr-08 4:40 
Questionhow to get back and next record from databases Pin
ilu_f94-Apr-08 3:58
ilu_f94-Apr-08 3:58 
AnswerRe: how to get back and next record from databases Pin
Rick van Woudenberg4-Apr-08 4:06
Rick van Woudenberg4-Apr-08 4:06 
Generalrtf and streams Pin
panoskatws4-Apr-08 3:25
panoskatws4-Apr-08 3:25 
GeneralRe: rtf and streams Pin
Rick van Woudenberg4-Apr-08 3:34
Rick van Woudenberg4-Apr-08 3:34 
Hey,

I guess there are several ways of doing this. One way is :

//Load your text file<br />
            TextReader tr = new StreamReader("\\test.txt");<br />
<br />
            //How many lines should be loaded?<br />
            int NumberOfLines = 10;<br />
<br />
            //Make our array for each line<br />
            string[] ListLines = new string[NumberOfLines];<br />
<br />
            //Read the number of lines and put them in the array<br />
            for (int i = 1; i = NumberOfLines; i++)<br />
            {<br />
                ListLines[i] = tr.ReadLine();<br />
            }<br />
<br />
            //This will write the 5th line into the console<br />
            Console.WriteLine(ListLines[5]);<br />
            //This will write the 1st line into the console<br />
            Console.WriteLine(ListLines[1]);<br />
<br />
            Console.ReadLine();<br />
<br />
            // close the stream<br />
            tr.Close();


Another way of doing it , could be :


int counter = 0;<br />
string line;<br />
<br />
// Read the file and display it line by line.<br />
System.IO.StreamReader file = <br />
   new System.IO.StreamReader("c:\\test.txt");<br />
while((line = file.ReadLine()) != null && counter < 10)<br />
{<br />
   Console.WriteLine (line);<br />
   counter++;<br />
}<br />
<br />
file.Close();<br />
<br />
// Suspend the screen.<br />
Console.ReadLine();


You will have to play with it a little bit to get it right, but is not that hard.

Hope this helps Big Grin | :-D
GeneralRe: rtf and streams Pin
panoskatws4-Apr-08 4:20
panoskatws4-Apr-08 4:20 
GeneralRe: rtf and streams Pin
Rick van Woudenberg4-Apr-08 4:53
Rick van Woudenberg4-Apr-08 4:53 
GeneralRe: rtf and streams Pin
panoskatws5-Apr-08 4:54
panoskatws5-Apr-08 4:54 
GeneralRe: rtf and streams Pin
mav.northwind4-Apr-08 23:24
mav.northwind4-Apr-08 23:24 
GeneralRe: rtf and streams Pin
panoskatws5-Apr-08 5:16
panoskatws5-Apr-08 5:16 
GeneralThreading problem Pin
Rick van Woudenberg4-Apr-08 2:53
Rick van Woudenberg4-Apr-08 2:53 
GeneralRe: Threading problem Pin
leppie4-Apr-08 3:42
leppie4-Apr-08 3:42 
GeneralRe: Threading problem Pin
SeeBees4-Apr-08 16:15
SeeBees4-Apr-08 16:15 
GeneralRe: Threading problem Pin
S. Senthil Kumar5-Apr-08 13:56
S. Senthil Kumar5-Apr-08 13:56 
Questionis there a way to restrict possible values of a string param in a method Pin
Adam Harbour4-Apr-08 2:40
Adam Harbour4-Apr-08 2:40 
GeneralRe: is there a way to restrict possible values of a string param in a method Pin
Pete O'Hanlon4-Apr-08 2:50
mvePete O'Hanlon4-Apr-08 2:50 
GeneralWrong data returned! Pin
Graham_44-Apr-08 1:24
Graham_44-Apr-08 1:24 
GeneralPlugins for MS Office, Internet explorer using C# Pin
Vikas K.4-Apr-08 0:53
Vikas K.4-Apr-08 0:53 
GeneralRe: Plugins for MS Office, Internet explorer using C# Pin
John_Adams4-Apr-08 1:06
John_Adams4-Apr-08 1:06 
GeneralRe: Plugins for MS Office, Internet explorer using C# Pin
Vikas K.4-Apr-08 1:24
Vikas K.4-Apr-08 1:24 
GeneralRe: Plugins for MS Office, Internet explorer using C# Pin
Member 38312474-Apr-08 3:27
Member 38312474-Apr-08 3:27 
QuestionHow to get Keypress event to menuStrip Pin
ASysSolvers3-Apr-08 23:48
ASysSolvers3-Apr-08 23:48 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.