This is a known issue in the .NET Compact Framework v1.0. It was fixed in
Service Pack1.
Please note that, when you use SP1, you will need to set the Width property
to -1 after adding all items to the ListView.
Hope this helps.
Thank you,
Sergiy.
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
| From: Palm Kevin <
[email protected]>
| References: <Xu6#
[email protected]>
| X-Newsreader: AspNNTP 1.50 (ActionJackson.com)
| Subject: Re: ListView - Fit to width of column
| Mime-Version: 1.0
| Content-Type: text/plain; charset="us-ascii"
| Content-Transfer-Encoding: 7bit
| Message-ID: <
[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.compactframework
| Date: Tue, 16 Sep 2003 00:26:27 -0700
| NNTP-Posting-Host: actionjackson133.dsl.frii.net 216.17.147.133
| Lines: 1
| Path:
cpmsftngxa07.phx.gbl!cpmsftngxa10.phx.gbl!TK2MSFTNGXA05.phx.gbl!TK2MSFTNGP08
.phx.gbl!TK2MSFTNGP11.phx.gbl
| Xref: cpmsftngxa07.phx.gbl
microsoft.public.dotnet.framework.compactframework:33462
| X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework
|
| Here a simple smart-device-application that reproduces the problem :
| (Column-width fits to columnheader instead of content).
|
| using System;
| using System.Drawing;
| using System.Windows.Forms;
|
| namespace SmartDeviceApplication1
| {
| /// <summary>
| /// Summary description for Form1.
| /// </summary>
| public class Form1 : System.Windows.Forms.Form
| {
| private System.Windows.Forms.MainMenu mainMenu1;
|
| public Form1()
| {
| InitializeComponent();
| }
|
| #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.mainMenu1 = new System.Windows.Forms.MainMenu();
| this.Menu = this.mainMenu1;
| this.Text = "Form1";
| this.MinimizeBox = false;
| this.Controls.Add(generateTablePanel(this.Size,new string [,]{
| {"","Top casse","Montant casse","Quantités","Ventes (qtitées)"},
| {"Art1","Mini roulettes 250","9,72","6,00","22,00"},
| {"Art2","CO Choc'n choc","10,53","3,00","6,00"},
| {"Art3","Meurisse tablet","3,51","3,00","25,00"},
| {"Art4","C'or chokotoff","5,60","2,00","31,00"},
| {"Art5","Kinder delice","5,24","2,00","61,00"}}));
| }
| #endregion
|
| /// <summary>
| /// The main entry point for the application.
| /// </summary>
|
| static void Main()
| {
| Application.Run(new Form1());
| }
|
| private Panel generateTablePanel(Size panelSize,String[,] table)
| {
| Panel p = new Panel();
| p.Size = panelSize;
| // Create a new ListView control.
| ListView listView1 = new ListView();
|
| // Set the view to show details.
| listView1.View = View.Details;
|
| int columnCount = table.GetLength(1);
| int rowCount = table.GetLength(0);
|
| listView1.Size = Size;
| // Select the item and subitems when selection is made.
| listView1.FullRowSelect = true;
|
| // Create columns for the items and subitems.
| for(int column = 0; column < columnCount;column ++)
| {
| listView1.Columns.Add(table[0,column],-1,HorizontalAlignment.Left);
| }
|
| // Create items and sets of subitems for each item.
| ListViewItem item;
| for(int row = 1; row < rowCount; row++)
| {
| item = new ListViewItem(table[row,0]);
| for(int column = 1; column < columnCount;column ++)
| item.SubItems.Add(table[row,column]);
| listView1.Items.Add(item);
| }
|
| p.Controls.Add(listView1);
| return p;
| }
| }
| }
|
|
|
|
|
| Don't just participate in USENET...get rewarded for it!
|