C
Christoph Nahr
As the subject line says, the TextAlign property is ignored for the
first column of a Windows Forms ListView control. The text is always
left-aligned, regardless of which HorizontalAlignment value is used.
The following sample program demonstrates the bug with the .NET
Framework version 1.1. Note that both columns are set to right
alignment yet the first column is left-aligned:
using System.Windows.Forms;
public class MainClass {
public static void Main() {
Form form = new Form();
ListView list = new ListView();
list.Columns.Add("First", 100, HorizontalAlignment.Right);
list.Columns.Add("Second", 100, HorizontalAlignment.Right);
ListViewItem item = new ListViewItem(
new string[] { "foo", "bar" });
list.Items.Add(item);
list.Dock = DockStyle.Fill;
list.GridLines = true;
list.View = View.Details;
form.Controls.Add(list);
form.Show();
MessageBox.Show("Click OK to quit.");
}
}
first column of a Windows Forms ListView control. The text is always
left-aligned, regardless of which HorizontalAlignment value is used.
The following sample program demonstrates the bug with the .NET
Framework version 1.1. Note that both columns are set to right
alignment yet the first column is left-aligned:
using System.Windows.Forms;
public class MainClass {
public static void Main() {
Form form = new Form();
ListView list = new ListView();
list.Columns.Add("First", 100, HorizontalAlignment.Right);
list.Columns.Add("Second", 100, HorizontalAlignment.Right);
ListViewItem item = new ListViewItem(
new string[] { "foo", "bar" });
list.Items.Add(item);
list.Dock = DockStyle.Fill;
list.GridLines = true;
list.View = View.Details;
form.Controls.Add(list);
form.Show();
MessageBox.Show("Click OK to quit.");
}
}