對不起,一個簡單的問題:如何將datagridview的行/列寬設置爲datagridview的寬度?
我使用這個程序來顯示字符串列表到一個DataGridView:
List<string> MyDataSource = MyList.Select(x => Path.GetFileNameWithoutExtension(x)).ToList();
AllVideosGrid.DataSource = MyDataSource.ConvertAll(x => new { Value = x });
設計器生成的代碼:
// MyGrid
//
this.AllVideosGrid.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.AllVideosGrid.Location = new System.Drawing.Point(33, 185);
this.AllVideosGrid.Name = "AllVideosGrid";
this.AllVideosGrid.RowTemplate.Height = 24;
this.AllVideosGrid.Size = new System.Drawing.Size(319, 498);
this.AllVideosGrid.TabIndex = 32;
而且它還有顯示像這樣:
我想要將行的大小調整爲我在設計器中初始設置的datagridview大小。我怎樣才能做到這一點?
? – kennyzx
@kennyzx哦,對,。編輯!謝謝 –
嘗試AutoSizeColumnsMode填充 – kennyzx