询问者
一个winform程序,每次对设计界面有任何改动,然后运行都会提示:属性"Text"的代码生成失败。错误是未将对象的引用设置到对象的实例

问题
-
关闭提示窗口后程序照常运行,暂时未发现有什么不对。没有任何错误,警告。
不知道是不是我自己的dataGridView控件的问题,这是我控件的代码
namespace declareServer.myControlItems
{
public partial class dataGridViewWithIndex : DataGridView
{
SolidBrush solidBrush;
public dataGridViewWithIndex()
{
InitializeComponent();
solidBrush = new SolidBrush(this.RowHeadersDefaultCellStyle.ForeColor);
}protected override void OnRowPostPaint(DataGridViewRowPostPaintEventArgs e)
{
e.Graphics.DrawString((e.RowIndex + 1).ToString(), e.InheritedRowStyle.Font, solidBrush, e.RowBounds.Location.X + 15, e.RowBounds.Location.Y + 5);
base.OnRowPostPaint(e);
}
}
}
全部回复
-
-
你好:
欢迎来到MSDN 中文论坛。
请问你使用的是Visual Studio的哪个版本,在VS2008和2010中可能会出现这个问题,有可能是设计器的一个BUG,建议到Microsoft Connect上去提出你的问题。
参考以下两篇博客:
VS2010中WinForm中,“属性<属性名>的代码生成失败”的问题
尝试一下第二篇博客中的方法,在相应属性上添加以下特性:
[System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden), System.ComponentModel.Browsable(false)]
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click HERE to participate the survey.- 已编辑 CaillenModerator 2014年4月8日 5:28
-
你好:
欢迎来到MSDN 中文论坛。
请问你使用的是Visual Studio的哪个版本,在VS2008和2010中可能会出现这个问题,有可能是设计器的一个BUG
尝试一下第二篇博客中的方法,在相应属性上添加以下特性:
[System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden), System.ComponentModel.Browsable(false)]
我的是vs2010。
不知道这句话去哪填加,我不知道是什么控件的text属性,完全没有报错啊。