Column Header Not dispalying text in center
-
Hi All Here is the code below // List view items starts here. ListView listView = new ListView(); listView.Bounds = new Rectangle(new Point(3, 16), new Size(900,900)); // Set the view to show details. listView.View = View.Details; // Allow the user to rearrange columns. listView.AllowColumnReorder = true; // Display check boxes. listView.CheckBoxes = true; // Select the item and subitems when selection is made. listView.FullRowSelect = true; // Display grid lines. listView.GridLines = true; listView.Visible=true; listView.Columns.Add("File Name", 100, HorizontalAlignment.Center); listView.Columns.Add("File Location", 100, HorizontalAlignment.Center); listView.Columns.Add("File size", 100, HorizontalAlignment.Center); // Add the ListView to the control collection. this.Controls.Add(listView); The text in first column header is aligned to left although i have aligned it to center. The text in other two columns header is aligned to center as set by me. How can i make the text in first column header to aligned centerally. Thanks in advance
-
Hi All Here is the code below // List view items starts here. ListView listView = new ListView(); listView.Bounds = new Rectangle(new Point(3, 16), new Size(900,900)); // Set the view to show details. listView.View = View.Details; // Allow the user to rearrange columns. listView.AllowColumnReorder = true; // Display check boxes. listView.CheckBoxes = true; // Select the item and subitems when selection is made. listView.FullRowSelect = true; // Display grid lines. listView.GridLines = true; listView.Visible=true; listView.Columns.Add("File Name", 100, HorizontalAlignment.Center); listView.Columns.Add("File Location", 100, HorizontalAlignment.Center); listView.Columns.Add("File size", 100, HorizontalAlignment.Center); // Add the ListView to the control collection. this.Controls.Add(listView); The text in first column header is aligned to left although i have aligned it to center. The text in other two columns header is aligned to center as set by me. How can i make the text in first column header to aligned centerally. Thanks in advance
The first column in a listview is always aligned to the left, regardless of what you set it to. There is no option to change this. If you want a centered first column, use a DataGridView instead.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007, 2008