我有一個列表視圖,它有一列。該視圖設置爲列表,我可以看到每個Listviewitem,但我無法選擇該項目的行,我必須選擇該項目的文本。是否有可能使Listviewitem的寬度與Listview本身的大小相同,以便用戶可以單擊Listviewitem上的任意位置來選擇該項目?Set Listviewitem的寬度
我試過搜索,但只能找到如何更改列寬以及如何修復它在XAML,但這是一個WinForm。
編輯 - 根據要求,這是由Visual Studio設計器生成的代碼。它是與ListviewItem有關的唯一代碼。
System.Windows.Forms.ListViewItem listViewItem1 = new System.Windows.Forms.ListViewItem("1");
System.Windows.Forms.ListViewItem listViewItem2 = new System.Windows.Forms.ListViewItem("2");
System.Windows.Forms.ListViewItem listViewItem3 = new System.Windows.Forms.ListViewItem("3");
System.Windows.Forms.ListViewItem listViewItem4 = new System.Windows.Forms.ListViewItem("4");
System.Windows.Forms.ListViewItem listViewItem5 = new System.Windows.Forms.ListViewItem("5");
System.Windows.Forms.ListViewItem listViewItem6 = new System.Windows.Forms.ListViewItem("6");
System.Windows.Forms.ListViewItem listViewItem7 = new System.Windows.Forms.ListViewItem("7");
this.listView1 = new System.Windows.Forms.ListView();
this.listView1.Activation = System.Windows.Forms.ItemActivation.OneClick;
this.listView1.AllowDrop = true;
this.listView1.AutoArrange = false;
this.listView1.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.listView1.Font = new System.Drawing.Font("Microsoft Sans Serif", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.listView1.ForeColor = System.Drawing.SystemColors.MenuHighlight;
this.listView1.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.None;
listViewItem1.StateImageIndex = 0;
this.listView1.Items.AddRange(new System.Windows.Forms.ListViewItem[] {
listViewItem1,
listViewItem2,
listViewItem3,
listViewItem4,
listViewItem5,
listViewItem6,
listViewItem7});
this.listView1.Location = new System.Drawing.Point(105, 129);
this.listView1.Name = "listView1";
this.listView1.Size = new System.Drawing.Size(157, 475);
this.listView1.TabIndex = 4;
this.listView1.UseCompatibleStateImageBehavior = false;
this.listView1.View = System.Windows.Forms.View.List;
爲什麼:
該項目自動調整大小可以通過設置AutoSizeItemsInDetailsView屬性真正被觸發這是downvoted?沒有代碼可以顯示,它是一個標準的Listview控件。有人可以解釋我在問題中做了什麼錯誤,以便我可以修復它嗎? – Moleman
WPF或WinForms?在XAML或代碼中? – dans3itz
dans3itz,它是WinForms和代碼。是否有財產設置? – Moleman