尽管UseColumnTextForButtonText设置为true,但DataGridView按钮文本仍未显示

Kai*_*Kai 3 .net c# winforms .net-4.5

我已经向DataGridView添加了一个按钮列,并希望在其上显示"比较"文本.我已将Text属性设置为Compare和UseColumnTextForButtonValueTrue,但不显示任何文本:

属性设置,没有文本可见

这在运行时也是如此,因此它不仅不在设计器中显示:

运行时也没有文本

如何显示文本?

编辑:为了繁荣,这里是生成的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;
Run Code Online (Sandbox Code Playgroud)

小智 5

DataGridViewButtonColumn不显示最后一行按钮中的文本.由于在您的示例中您只显示一行,因此未显示.添加更多行,文本将显示在除最后一行之外的所有行中.