尽管 UseColumnTextForButtonText 设置为 true,但 DataGridView 按钮文本没有出现 [英] DataGridView button text not appearing despite UseColumnTextForButtonText set to true

查看:28
本文介绍了尽管 UseColumnTextForButtonText 设置为 true,但 DataGridView 按钮文本没有出现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已向 DataGridView 添加了一个按钮列,并希望在其上显示文本比较".我已将 Text 属性设置为 Compare 并将 UseColumnTextForButtonValue 设置为 True,但没有显示文本:

I've added a button column to a DataGridView and want to display the text "Compare" on it. I've set the Text property to Compare and UseColumnTextForButtonValue to True, but no text displays:

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

This is also true at runtime, so it's not just not displaying in the designer:

如何让文字出现?

为了繁荣,这里是生成的 Designer.cs 文件中的代码.我自己还没有在这个表单中添加任何代码,所以不可能有什么东西会进一步重置它.

For prosperity's sake, here's the code in the generated Designer.cs file. I haven't added any code to this form myself yet, so there's no chance that something's resetting it further down the line.

// 
// 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 不显示最后一行按钮中的文本.由于在您的示例中您只显示一行,因此未显示.添加更多行,文本将出现在除最后一行之外的所有行中.

DataGridViewButtonColumn does not display the text in the button on the last row. Since in your example you only display one row, it is not shown. Add some more rows, and the text will appear in all but the last row.

这篇关于尽管 UseColumnTextForButtonText 设置为 true,但 DataGridView 按钮文本没有出现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆