c# escape characters cause [] in listview

Please support our C# advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Jan 2008
Posts: 2,052
Reputation: serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light 
Solved Threads: 123
Featured Poster
serkan sendur serkan sendur is offline Offline
Postaholic

c# escape characters cause [] in listview

 
1
  #1
Sep 21st, 2009
the following escape sequences cause [] in listview. Is there any way to fix it?

Form1.cs :
  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 :

  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, 4 views)
Due to lack of freedom of speech, i no longer post on this website.
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 114
Reputation: papanyquiL is on a distinguished road 
Solved Threads: 11
papanyquiL papanyquiL is offline Offline
Junior Poster

Re: c# escape characters cause [] in listview

 
0
  #2
Sep 21st, 2009
Hmm, I'm not getting "[]," I'm getting "{
1234 5 6 7}"
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 2,044
Reputation: ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of 
Solved Threads: 309
ddanbe's Avatar
ddanbe ddanbe is offline Offline
Postaholic

Re: c# escape characters cause [] in listview

 
1
  #3
Sep 21st, 2009
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.
Today is a gift, that's why it is called "The Present".
Make love, no war. Cave ab homine unius libri.
Danny
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 114
Reputation: papanyquiL is on a distinguished road 
Solved Threads: 11
papanyquiL papanyquiL is offline Offline
Junior Poster

Re: c# escape characters cause [] in listview

 
0
  #4
Sep 21st, 2009
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?
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 972
Reputation: DdoubleD is a jewel in the rough DdoubleD is a jewel in the rough DdoubleD is a jewel in the rough DdoubleD is a jewel in the rough 
Solved Threads: 213
DdoubleD DdoubleD is offline Offline
Posting Shark

Re: c# escape characters cause [] in listview

 
0
  #5
Sep 21st, 2009
I had the same concerns you guys did about what was being done in his ListView--it seems like a futile exercise to me.
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 2,052
Reputation: serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light 
Solved Threads: 123
Featured Poster
serkan sendur serkan sendur is offline Offline
Postaholic

Re: c# escape characters cause [] in listview

 
0
  #6
Sep 21st, 2009
it does not cause [] in vista, but causes in XP.
could you verify?
Due to lack of freedom of speech, i no longer post on this website.
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 114
Reputation: papanyquiL is on a distinguished road 
Solved Threads: 11
papanyquiL papanyquiL is offline Offline
Junior Poster

Re: c# escape characters cause [] in listview

 
0
  #7
Sep 21st, 2009
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.
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 972
Reputation: DdoubleD is a jewel in the rough DdoubleD is a jewel in the rough DdoubleD is a jewel in the rough DdoubleD is a jewel in the rough 
Solved Threads: 213
DdoubleD DdoubleD is offline Offline
Posting Shark

Re: c# escape characters cause [] in listview

 
0
  #8
Sep 21st, 2009
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?
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 2,052
Reputation: serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light 
Solved Threads: 123
Featured Poster
serkan sendur serkan sendur is offline Offline
Postaholic

Re: c# escape characters cause [] in listview

 
0
  #9
Sep 21st, 2009
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.
Due to lack of freedom of speech, i no longer post on this website.
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 2,052
Reputation: serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light 
Solved Threads: 123
Featured Poster
serkan sendur serkan sendur is offline Offline
Postaholic

Re: c# escape characters cause [] in listview

 
0
  #10
Sep 21st, 2009
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

?
Due to lack of freedom of speech, i no longer post on this website.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:




Views: 1036 | Replies: 18
Thread Tools Search this Thread



Tag cloud for C#
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC