Click here to Skip to main content
15,920,503 members
Home / Discussions / C#
   

C#

 
GeneralRe: BackGroundImage of MDIForm in C#.Net Pin
Harshalbhakta21-Nov-05 14:28
Harshalbhakta21-Nov-05 14:28 
GeneralRe: BackGroundImage of MDIForm in C#.Net Pin
newpant22-Nov-05 1:31
newpant22-Nov-05 1:31 
Questiondisplay chronometer connected to parrallel port Pin
el_aristo20-Nov-05 2:11
el_aristo20-Nov-05 2:11 
Questionhow to use button to open the new form Pin
activesync20-Nov-05 2:05
activesync20-Nov-05 2:05 
AnswerRe: how to use button to open the new form Pin
Jeff Bramwell20-Nov-05 2:36
Jeff Bramwell20-Nov-05 2:36 
Questionparallel port display chronometer Pin
el_aristo20-Nov-05 1:48
el_aristo20-Nov-05 1:48 
QuestionPopulating datagrid from csv stream Pin
rana7420-Nov-05 0:08
rana7420-Nov-05 0:08 
AnswerRe: Populating datagrid from csv stream Pin
Curtis Schlak.20-Nov-05 15:29
Curtis Schlak.20-Nov-05 15:29 
If you just want to display it in HTML and don't need the DataGrid, you can do it the old fashioned way and parse the file using these rules.


  1. Write <table> to your output stream
  2. While your input stream has characters left:

    1. Read a line (or to the end) from your input stream.
    2. Write "" to your output stream.
    3. Replace all commas not inside a balanced set of quotation marks with </td><td>.
    4. Replace all </td><td>" with </td><td>.
    5. Replace all "</td><td> with </td><td>.
    6. Replace all "" with ".
    7. If the first character of the line is ", remove it.
    8. If the last character of the line is ", remove it.
    9. Write the modified string to the output stream.
    10. Write "" to your output stream.

  3. Write </table> to your output stream.


Now, you have a table with your CSV in it.

For example, following that replacement rule set with the string 1,2,3,4,"I say""Hello,"" and you don't","Com,ma", we get the following replacements:

1,2,3,4,"I say""Hello,"" and you don't","Com,ma"

// Replace all commas not inside a balanced set of
// quotation marks with </td><td>
1</td><td>2</td><td>3</td><td>4</td><td>"I say""Hello,"" and you don't"</td><td>"Com,ma"

// Replace all </td><td>" with </td><td>.
1</td><td>2</td><td>3</td><td>4</td><td>I say""Hello,"" and you don't"</td><td>Com,ma"

// Replace all "</td><td> with </td><td>.
1</td><td>2</td><td>3</td><td>4</td><td>I say""Hello,"" and you don't</td><td>Com,ma"

// Replace all "" with ".
1</td><td>2</td><td>3</td><td>4</td><td>I say"Hello," and you don't</td><td>Com,ma"

// If the first character of the line is ", remove it.
1</td><td>2</td><td>3</td><td>4</td><td>I say"Hello," and you don't</td><td>Com,ma"

// If the last character of the line is ", remove it.
1</td><td>2</td><td>3</td><td>4</td><td>I say"Hello," and you don't</td><td>Com,ma


"we must lose precision to make significant
      statements about complex systems."
              -deKorvin on uncertainty

Questiontreeview Pin
F.Hashemi19-Nov-05 23:55
F.Hashemi19-Nov-05 23:55 
AnswerRe: treeview Pin
Jeff Bramwell20-Nov-05 2:39
Jeff Bramwell20-Nov-05 2:39 
AnswerRe: treeview Pin
Curtis Schlak.20-Nov-05 6:35
Curtis Schlak.20-Nov-05 6:35 
QuestionDataGrid &amp; DataRelation Pin
RoyRose7819-Nov-05 20:10
RoyRose7819-Nov-05 20:10 
Questionstrongly typed collections over web services Pin
(Steven Hicks)n+119-Nov-05 18:37
(Steven Hicks)n+119-Nov-05 18:37 
QuestionREGEX Expressions Pin
Expert Coming19-Nov-05 17:09
Expert Coming19-Nov-05 17:09 
AnswerRe: REGEX Expressions Pin
User 665820-Nov-05 1:14
User 665820-Nov-05 1:14 
QuestionIs this reflection? Pin
eggie519-Nov-05 16:24
eggie519-Nov-05 16:24 
AnswerRe: Is this reflection? Pin
eggie519-Nov-05 16:56
eggie519-Nov-05 16:56 
AnswerRe: Is this reflection? Pin
Stanciu Vlad19-Nov-05 22:30
Stanciu Vlad19-Nov-05 22:30 
GeneralRe: Is this reflection? Pin
User 665820-Nov-05 1:26
User 665820-Nov-05 1:26 
GeneralRe: Is this reflection? Pin
Stanciu Vlad20-Nov-05 4:50
Stanciu Vlad20-Nov-05 4:50 
GeneralRe: Is this reflection? Pin
eggie520-Nov-05 8:40
eggie520-Nov-05 8:40 
GeneralRe: Is this reflection? Pin
eggie520-Nov-05 8:53
eggie520-Nov-05 8:53 
GeneralRe: Is this reflection? Pin
Stanciu Vlad20-Nov-05 10:01
Stanciu Vlad20-Nov-05 10:01 
QuestionHelp with Delegates and Events Pin
tawammar19-Nov-05 11:37
tawammar19-Nov-05 11:37 
AnswerRe: Help with Delegates and Events Pin
mikanu19-Nov-05 21:09
mikanu19-Nov-05 21:09 

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.