在.Designer文件中,我有一个DataGridViewCellStyle
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStylePhoto = new System.Windows.Forms.DataGridViewCellStyle();
this.photoDataGridViewTextBoxColumn.DefaultCellStyle = dataGridViewCellStylePhoto;每当我在Visual中更改与此无关的内容时,它都会坚持将其重命名如下:
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
this.photoDataGridViewTextBoxColumn.DefaultCellStyle = dataGridViewCellStyle1;为什么?我怎么才能阻止这一切?
发布于 2018-05-31 19:00:02
在.Designer文件中,我有一个
DataGridViewCellStyle.每当我在Visual中更改与此无关的内容时,它都会坚持重命名.
为什么?
每当您更改表单设计器中的任何内容时,InitializeComponent方法的全部内容都将再次重新生成。这就是Windows窗体设计器的工作方式。
对于所有IComponent实现,生成的代码中变量的名称将与组件的名称相同。
我怎样才能阻止这一切?
保持DataGridViewCellStyle的变量名并不容易,因为它不是IComponent的实现,而且designer不存储任何关于它的名称的信息,变量的名称是动态生成的。
https://stackoverflow.com/questions/50628477
复制相似问题