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

Form1.cs :

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace newLineInListView
{
	public partial class Form1 : Form
	{
		public Form1()
		{
			InitializeComponent();
		}

		private void Form1_Load(object sender, EventArgs e)
		{
			StringBuilder sb = new StringBuilder();
			sb.Append("\r");
			sb.Append("1");
			sb.Append("\n");
			sb.Append("2");
			sb.Append("\a");
			sb.Append("3");
			sb.Append("\b");
			sb.Append("4");
			sb.Append("\f");
			sb.Append("5");
			sb.Append("\t");
			sb.Append("6");
			sb.Append("\v");
			sb.Append("7");
			ListViewItem lvi = new ListViewItem(sb.ToString());
			listView1.Items.Add(lvi);
		}
	}
}

Form1.Designer.cs :

namespace newLineInListView
{
	partial class Form1
	{
		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.IContainer components = null;

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
		protected override void Dispose(bool disposing)
		{
			if (disposing && (components != null))
			{
				components.Dispose();
			}
			base.Dispose(disposing);
		}

		#region Windows Form Designer generated code

		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			this.listView1 = new System.Windows.Forms.ListView();
			this.columnHeader1 = new System.Windows.Forms.ColumnHeader();
			this.SuspendLayout();
			// 
			// listView1
			// 
			this.listView1.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
            this.columnHeader1});
			this.listView1.Location = new System.Drawing.Point(71, 25);
			this.listView1.Name = "listView1";
			this.listView1.Size = new System.Drawing.Size(250, 145);
			this.listView1.TabIndex = 0;
			this.listView1.UseCompatibleStateImageBehavior = false;
			this.listView1.View = System.Windows.Forms.View.Details;
			// 
			// Form1
			// 
			this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
			this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
			this.ClientSize = new System.Drawing.Size(409, 289);
			this.Controls.Add(this.listView1);
			this.Name = "Form1";
			this.Text = "Form1";
			this.Load += new System.EventHandler(this.Form1_Load);
			this.ResumeLayout(false);

		}

		#endregion

		private System.Windows.Forms.ListView listView1;
		private System.Windows.Forms.ColumnHeader columnHeader1;
	}
}

Project is attached.

commented: Good question but I think you have an answer. +17

Hmm, I'm not getting "[]," I'm getting "{
12345 67}"

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.

commented: Because - "Serkan wants to store esc seq. chars" +17

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?

I had the same concerns you guys did about what was being done in his ListView--it seems like a futile exercise to me.

it does not cause [] in vista, but causes in XP.
could you verify?

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.

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?

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.

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

?

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

?

Neither: "change its name to be "blah blah"

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

?

Neither, it's 'change its name to blahblah.'

Or, Change its name to: blah blah

Come on guys, sometimes you want to make a sentence sound more dramatic or drastic. if you were to put as somewhere there, how would you insert it? I want that to sound more important than a simple name change.

Then say this:

"Change its name to <name>." Simple yet effective. :)

commented: LOL +13

OwnerDraw listview; It expands escape seq,. chars.

....
listView1.OwnerDraw = true;
listView1.DrawItem += new DrawListViewItemEventHandler(listView1_DrawItem);
}

void listView1_DrawItem(object sender, DrawListViewItemEventArgs e)
 {
 e.DrawText(TextFormatFlags.Default | TextFormatFlags.ExpandTabs | TextFormatFlags.ExternalLeading );
  }
commented: genius +9

OwnerDraw listview; It expands escape seq,. chars.

....
listView1.OwnerDraw = true;
listView1.DrawItem += new DrawListViewItemEventHandler(listView1_DrawItem);
}

void listView1_DrawItem(object sender, DrawListViewItemEventArgs e)
 {
 e.DrawText(TextFormatFlags.Default | TextFormatFlags.ExpandTabs | TextFormatFlags.ExternalLeading );
  }

Thanks a lot, this is incredible, i havent tried yet but it is very exciting , this is out of the box thinking...

it doesnt seem to work
Form1.cs :

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace newLineInListView
{
	public partial class Form1 : Form
	{
		public Form1()
		{
			InitializeComponent();
		}

		private void Form1_Load(object sender, EventArgs e)
		{
			StringBuilder sb = new StringBuilder();
			sb.Append("\r");
			sb.Append("1");
			sb.Append("\n");
			sb.Append("2");
			sb.Append("\a");
			sb.Append("3");
			sb.Append("\b");
			sb.Append("4");
			sb.Append("\f");
			sb.Append("5");
			sb.Append("\t");
			sb.Append("6");
			sb.Append("\v");
			sb.Append("7");
			ListViewItem lvi = new ListViewItem(sb.ToString());
			listView1.Items.Add(lvi);
		}

		private void listView1_DrawItem(object sender, DrawListViewItemEventArgs e)
		{
			e.DrawText(TextFormatFlags.Default | TextFormatFlags.ExpandTabs | TextFormatFlags.ExternalLeading);
		}
	}
}

You are right serkan. It expands newline, carriage return and tab char only.