【发布时间】:2018-05-31 16:05:05
【问题描述】:
在 .Designer 文件中,我有一个 DataGridViewCellStyle:
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStylePhoto = new System.Windows.Forms.DataGridViewCellStyle();
this.photoDataGridViewTextBoxColumn.DefaultCellStyle = dataGridViewCellStylePhoto;
每当我在可视化编辑器中更改一些与此无关的内容时,它都会坚持这样重命名:
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
this.photoDataGridViewTextBoxColumn.DefaultCellStyle = dataGridViewCellStyle1;
为什么?我怎样才能防止这种情况发生?
【问题讨论】:
-
他们总结性地告诉我们“设计器支持所需的方法 - 不要使用代码编辑器修改此方法的内容。”您是否在 Designer.cs 中编辑某些内容并在 [design] 中执行其他操作?
-
你无法阻止它。
-
@Amit:无论如何都会发生。直接在源代码中编辑或使用[设计]中的可视化编辑器
-
为什么不在普通的代码隐藏文件中改变它呢?这永远不会被覆盖,不像设计器每次都会重新生成。
-
@Alejandro 那么你将失去设计时支持。
标签: c# .net winforms windows-forms-designer