尽管UseColumnTextForButtonText设置为true,但DataGridView按钮文本仍未显示
我已经向DataGridView添加了一个按钮列,并希望在其上显示“比较”文本。 我已将Text
属性设置为Compare并将UseColumnTextForButtonValue
为True,但不显示任何文本:
这在运行时也是如此,因此它不仅不在设计器中显示:
如何显示文本?
编辑:为了繁荣,这里是生成的Designer.cs文件中的代码。 我自己还没有在这个表单中添加任何代码,所以没有任何东西可以让它重新进一步重置。
// // Compare // dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; dataGridViewCellStyle1.Font = new System.Drawing.Font("Calibri", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.Compare.DefaultCellStyle = dataGridViewCellStyle1; this.Compare.HeaderText = "Compare"; this.Compare.Name = "Compare"; this.Compare.Text = "Compare"; this.Compare.ToolTipText = "Compare the dictionary definition to the system definition"; this.Compare.UseColumnTextForButtonValue = true;
DataGridViewButtonColumn不显示最后一行按钮中的文本。 由于在您的示例中您只显示一行,因此未显示。 添加更多行,文本将显示在除最后一行之外的所有行中。
Kif得到了正确的答案:
DataGridViewButtonColumn不显示最后一行按钮中的文本。 添加更多行,文本将显示在除最后一行之外的所有行中。
但如果你想要显示你想要的文本(包括最后一行),你可以简单地实现事件处理程序CellValueChanged
并设置像这样的单元格值:
_yourDataGridView[Compare.Name, rowIndex].Value = "Compire";
您可以设置“UseColumnTextForButtonValue”,然后也会显示最后一行的文本。