c# - How to set automatic width? -


I would like to use some "dock" for the listview column I want to set the minimum width, but I want to fill the entire ListView width, which is set to dock fill .

Is this possible? It would be nice to be able to set the column width as a percentage value of its length. I was searching the web and many people said to width 2, but it does not work for me

You have two basic options:

  • You You can choose one of Column Header Auto Resize Style options: ColumnContent , header size or none . The alternatives suggest their names. Note that they apply only when you set them up. This means that to add HeaderSize you have to add the first column, set the then option. And column content , you need to fill the first column and items with your content to work!

  • Or you can choose the script to resize the resize event to the column size of your choice. I add the code that changes each column again. So that the ListView is filled up and each column keeps its old percentage width.

A little extra coding will also be enabled by adding options:

  • To set the same options for all the columns Instead of using AutoResizeColumns , AutoResizeColumn sets the option for a single column.

  • If you want the column to not be part of a patterned shape, you can mark it in some way; For a simple implementation, I chose to set my column to set my Tag = "#"

The only option is:

  listView1.AutoResizeColumns (Column header Autorrection Style .column content); ListView1.AutoResizeColumns (ColumnHeaderAutoResizeStyle.HeaderSize); ListView1.AutoResizeColumns (ColumnHeaderAutoResizeStyle.None);  

And there is a resizing code that keeps all columns related to its relative width, while still fills the ListView:

  See Private Zero List 1_size (object sender, EventArgs e) {int oldsum = 0; Voroch (column headers in the list. View 1. Column) old = + ch.Width; Forex currency (column headers in the list, see visual 1. column) {if (ch.Tag! = "#") Ch.Width = ch.Width * listView1.ClientSize.Width / oldsum; }}  

Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -