943,553 Members | Top Members by Rank

Ad:
  • C# Discussion Thread
  • Marked Solved
  • Views: 2273
  • C# RSS
You are currently viewing page 1 of this multi-page discussion thread
Sep 21st, 2009
1

c# escape characters cause [] in listview

Expand Post »
the following escape sequences cause [] in listview. Is there any way to fix it?

Form1.cs :
C# Syntax (Toggle Plain Text)
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Text;
  7. using System.Windows.Forms;
  8.  
  9. namespace newLineInListView
  10. {
  11. public partial class Form1 : Form
  12. {
  13. public Form1()
  14. {
  15. InitializeComponent();
  16. }
  17.  
  18. private void Form1_Load(object sender, EventArgs e)
  19. {
  20. StringBuilder sb = new StringBuilder();
  21. sb.Append("\r");
  22. sb.Append("1");
  23. sb.Append("\n");
  24. sb.Append("2");
  25. sb.Append("\a");
  26. sb.Append("3");
  27. sb.Append("\b");
  28. sb.Append("4");
  29. sb.Append("\f");
  30. sb.Append("5");
  31. sb.Append("\t");
  32. sb.Append("6");
  33. sb.Append("\v");
  34. sb.Append("7");
  35. ListViewItem lvi = new ListViewItem(sb.ToString());
  36. listView1.Items.Add(lvi);
  37. }
  38. }
  39. }

Form1.Designer.cs :

C# Syntax (Toggle Plain Text)
  1. namespace newLineInListView
  2. {
  3. partial class Form1
  4. {
  5. /// <summary>
  6. /// Required designer variable.
  7. /// </summary>
  8. private System.ComponentModel.IContainer components = null;
  9.  
  10. /// <summary>
  11. /// Clean up any resources being used.
  12. /// </summary>
  13. /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
  14. protected override void Dispose(bool disposing)
  15. {
  16. if (disposing && (components != null))
  17. {
  18. components.Dispose();
  19. }
  20. base.Dispose(disposing);
  21. }
  22.  
  23. #region Windows Form Designer generated code
  24.  
  25. /// <summary>
  26. /// Required method for Designer support - do not modify
  27. /// the contents of this method with the code editor.
  28. /// </summary>
  29. private void InitializeComponent()
  30. {
  31. this.listView1 = new System.Windows.Forms.ListView();
  32. this.columnHeader1 = new System.Windows.Forms.ColumnHeader();
  33. this.SuspendLayout();
  34. //
  35. // listView1
  36. //
  37. this.listView1.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
  38. this.columnHeader1});
  39. this.listView1.Location = new System.Drawing.Point(71, 25);
  40. this.listView1.Name = "listView1";
  41. this.listView1.Size = new System.Drawing.Size(250, 145);
  42. this.listView1.TabIndex = 0;
  43. this.listView1.UseCompatibleStateImageBehavior = false;
  44. this.listView1.View = System.Windows.Forms.View.Details;
  45. //
  46. // Form1
  47. //
  48. this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
  49. this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
  50. this.ClientSize = new System.Drawing.Size(409, 289);
  51. this.Controls.Add(this.listView1);
  52. this.Name = "Form1";
  53. this.Text = "Form1";
  54. this.Load += new System.EventHandler(this.Form1_Load);
  55. this.ResumeLayout(false);
  56.  
  57. }
  58.  
  59. #endregion
  60.  
  61. private System.Windows.Forms.ListView listView1;
  62. private System.Windows.Forms.ColumnHeader columnHeader1;
  63. }
  64. }

Project is attached.
Attached Files
File Type: zip newLineInListView.zip (31.4 KB, 54 views)
Similar Threads
Featured Poster
Reputation Points: 854
Solved Threads: 127
Banned
serkan sendur is offline Offline
2,057 posts
since Jan 2008
Sep 21st, 2009
0

Re: c# escape characters cause [] in listview

Hmm, I'm not getting "[]," I'm getting "{
1234 5 6 7}"
Reputation Points: 55
Solved Threads: 18
Junior Poster
papanyquiL is offline Offline
168 posts
since May 2009
Sep 21st, 2009
1

Re: c# escape characters cause [] in listview

Getting te same.
But why does someone wants to display \a in a ListVIEW?
\a is the alert or bell character, I believe it is ASCII 7 so it is below ASCII 32(the space) and is as such non printable. Same as opening excel.exe in Word. Looks like rubbish because of the non printables.
Reputation Points: 2023
Solved Threads: 644
Senior Poster
ddanbe is offline Offline
3,735 posts
since Oct 2008
Sep 21st, 2009
0

Re: c# escape characters cause [] in listview

I'm not even sure you can use some of those escape sequences in a listView, such as \n, can you? I don't think listview sorts things like textboxes, richtextboxes, etc... It's sorts by rows or columns so I don't even think a line return would work; or am I completely off on that?
Reputation Points: 55
Solved Threads: 18
Junior Poster
papanyquiL is offline Offline
168 posts
since May 2009
Sep 21st, 2009
0

Re: c# escape characters cause [] in listview

I had the same concerns you guys did about what was being done in his ListView--it seems like a futile exercise to me.
Reputation Points: 341
Solved Threads: 233
Posting Shark
DdoubleD is offline Offline
984 posts
since Jul 2009
Sep 21st, 2009
0

Re: c# escape characters cause [] in listview

it does not cause [] in vista, but causes in XP.
could you verify?
Featured Poster
Reputation Points: 854
Solved Threads: 127
Banned
serkan sendur is offline Offline
2,057 posts
since Jan 2008
Sep 21st, 2009
0

Re: c# escape characters cause [] in listview

Since the listview doesn't accept some of the linefeed commands, etc.., it shows the command as a special character. I'm guessing some of the characters differ in ALT codes between XP and Vista. Thus, the special character being displayed in Vista (or win7 in my case) would be read and displayed as a "[, ]" in XP.
Reputation Points: 55
Solved Threads: 18
Junior Poster
papanyquiL is offline Offline
168 posts
since May 2009
Sep 21st, 2009
0

Re: c# escape characters cause [] in listview

Why does your data contain such escape sequences and why not scrub them out first before adding them if you need to display in a ListView control?
Reputation Points: 341
Solved Threads: 233
Posting Shark
DdoubleD is offline Offline
984 posts
since Jul 2009
Sep 21st, 2009
0

Re: c# escape characters cause [] in listview

they are some seperators showing some hierarchical relation between strings. i can not remove them. but anyway i think this is a known issue, i am not alone and i am going to mark this thread as solved by contributing to y'all's solved threads.
Featured Poster
Reputation Points: 854
Solved Threads: 127
Banned
serkan sendur is offline Offline
2,057 posts
since Jan 2008
Sep 21st, 2009
0

Re: c# escape characters cause [] in listview

By the way i have a question for native english speakers : which one is correct
1) change its name as to be blah blah
2) change its name to be as blah blah

?
Featured Poster
Reputation Points: 854
Solved Threads: 127
Banned
serkan sendur is offline Offline
2,057 posts
since Jan 2008

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C# Forum Timeline: C# tool help
Next Thread in C# Forum Timeline: Retrieving records in batches of 50





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC