本文介绍了DataGridView的设置行高度不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
想设置的rowHeight像这样(代码):
Trying to set RowHeight like this(in code):
dgvTruckAvail.RowTemplate.Height = 48;
犯规的工作。我也试图设置我添加的每个柱的高度 - 不工作
Doesnt' work. I also tried to set Height of every colum I add - doesn't work.
下面是网格属性:
this.dgvTruckAvail.AllowUserToAddRows = false;
this.dgvTruckAvail.AllowUserToDeleteRows = false;
this.dgvTruckAvail.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.dgvTruckAvail.BackgroundColor = System.Drawing.Color.White;
this.dgvTruckAvail.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.dgvTruckAvail.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.None;
this.dgvTruckAvail.Columns.AddRange(
new System.Windows.Forms.DataGridViewColumn[]
{
this.colMon,
this.colTue,
this.colWED,
this.colThu,
this.colFri,
this.colSat,
this.colSun});
this.dgvTruckAvail.Cursor = System.Windows.Forms.Cursors.Default;
dataGridViewCellStyle8.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
dataGridViewCellStyle8.BackColor = System.Drawing.SystemColors.Window;
dataGridViewCellStyle8.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
dataGridViewCellStyle8.ForeColor = System.Drawing.SystemColors.ControlText;
dataGridViewCellStyle8.SelectionBackColor = System.Drawing.SystemColors.Window;
dataGridViewCellStyle8.SelectionForeColor = System.Drawing.SystemColors.ControlText;
dataGridViewCellStyle8.WrapMode = System.Windows.Forms.DataGridViewTriState.False;
this.dgvTruckAvail.DefaultCellStyle = dataGridViewCellStyle8;
this.dgvTruckAvail.EnableHeadersVisualStyles = false;
this.dgvTruckAvail.Location = new System.Drawing.Point(0, 22);
this.dgvTruckAvail.Margin = new System.Windows.Forms.Padding(4);
this.dgvTruckAvail.Name = "dgvTruckAvail";
this.dgvTruckAvail.ReadOnly = true;
this.dgvTruckAvail.RowHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.None;
this.dgvTruckAvail.RowTemplate.Height = 48;
this.dgvTruckAvail.RowTemplate.Resizable = System.Windows.Forms.DataGridViewTriState.True;
this.dgvTruckAvail.ShowCellToolTips = false;
this.dgvTruckAvail.Size = new System.Drawing.Size(1098, 394);
this.dgvTruckAvail.TabIndex = 0;
我不暴饮暴食格来填充。行手动添加和细胞手动填充。
你对此还有什么我可以尝试将其设置有什么建议?也许覆盖网格本身不知?
I'm not binging grid to populate. Rows added manually and cells populated manually.Do you have any suggestions on what else I can try to set it? Maybe override Grid itself somehow?
推荐答案
设置身高
各财产行做的工作。
foreach (DataGridViewRow row in dataGridView1.Rows)
{
row.Height = 80;
}
这篇关于DataGridView的设置行高度不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!