.NET VS win 窗体项目中的序列化顺序(设计器代码)问题
Problem with serialization order (designer code) in .NET VS win form project
根据我的其他 :
我得到了一个列表和一个我序列化的选定索引:
public interface IControlListManager
{
List<ControlListManager.TargetSettings> TargetList { get; set; }
int SelectedIndex { get; set; }
}
在designer.cs里面我得到了下面的序列化代码:
//...
controlListManager1.SelectedIndex = 0;
controlListManager1.TargetList.Add(new ControlListManager.TargetSettings(this, "", DisplayModes.FollowXY, true, 0, 0, 0));
controlListManager1.TargetList.Add(new ControlListManager.TargetSettings(this.InfoPanel, "", DisplayModes.FollowXY, true, 0, 0, 0));
controlListManager1.TargetList.Add(new ControlListManager.TargetSettings(this.InfoText, "", DisplayModes.FollowXY, true, 0, 0, 0));
controlListManager1.TargetList.Add(new ControlListManager.TargetSettings(this.HLine, "", DisplayModes.FollowXY, true, 0, 0, 0));
controlListManager1.TargetList.Add(new ControlListManager.TargetSettings(this.LogiDevType, "", DisplayModes.FollowXY, true, 0, 0, 0));
controlListManager1.TargetList.Add(new ControlListManager.TargetSettings(this.LogiDevSetBtn, "", DisplayModes.FollowXY, true, 0, 0, 0));
controlListManager1.TargetList.Add(new ControlListManager.TargetSettings(this.SystrayContextMenu, "", DisplayModes.FollowXY, true, 0, 0, 0));
controlListManager1.TargetList.Add(new ControlListManager.TargetSettings(this.restoreToolStripMenuItem, "", DisplayModes.FollowXY, true, 0, 0, 0));
controlListManager1.TargetList.Add(new ControlListManager.TargetSettings(this.exitToolStripMenuItem, "", DisplayModes.FollowXY, true, 0, 0, 0));
controlListManager1.TargetList.Add(new ControlListManager.TargetSettings(this.panel1, "", DisplayModes.FollowXY, true, 0, 0, 0));
controlListManager1.TargetList.Add(new ControlListManager.TargetSettings(this.IdentifierInput, "", DisplayModes.FollowXY, true, 0, 0, 0));
controlListManager1.TargetList.Add(new ControlListManager.TargetSettings(this.ExitButton, "", DisplayModes.FollowXY, true, 0, 0, 0));
controlListManager1.TargetList.Add(new ControlListManager.TargetSettings(this.IdentifierCheckbox, "", DisplayModes.FollowXY, true, 0, 0, 0));
controlListManager1.TargetList.Add(new ControlListManager.TargetSettings(this.SaveLogFile, "", DisplayModes.FollowXY, true, 0, 0, 0));
//...
问题是 SelectedIndex
应该在列表之后,因为它很好地代表了列表的索引。
如何告诉设计者将其放在列表之后?
因为我不想乱用 BeginInit() 和 EndInit() 方法(我真的应该这样做)并且发现,序列化程序顺序确实是按字母顺序排列的。
我将 SelectedIndex
重命名为 ZSelectedIndex
。有趣而肮脏 - 但快速解决方案。
根据我的其他
我得到了一个列表和一个我序列化的选定索引:
public interface IControlListManager
{
List<ControlListManager.TargetSettings> TargetList { get; set; }
int SelectedIndex { get; set; }
}
在designer.cs里面我得到了下面的序列化代码:
//...
controlListManager1.SelectedIndex = 0;
controlListManager1.TargetList.Add(new ControlListManager.TargetSettings(this, "", DisplayModes.FollowXY, true, 0, 0, 0));
controlListManager1.TargetList.Add(new ControlListManager.TargetSettings(this.InfoPanel, "", DisplayModes.FollowXY, true, 0, 0, 0));
controlListManager1.TargetList.Add(new ControlListManager.TargetSettings(this.InfoText, "", DisplayModes.FollowXY, true, 0, 0, 0));
controlListManager1.TargetList.Add(new ControlListManager.TargetSettings(this.HLine, "", DisplayModes.FollowXY, true, 0, 0, 0));
controlListManager1.TargetList.Add(new ControlListManager.TargetSettings(this.LogiDevType, "", DisplayModes.FollowXY, true, 0, 0, 0));
controlListManager1.TargetList.Add(new ControlListManager.TargetSettings(this.LogiDevSetBtn, "", DisplayModes.FollowXY, true, 0, 0, 0));
controlListManager1.TargetList.Add(new ControlListManager.TargetSettings(this.SystrayContextMenu, "", DisplayModes.FollowXY, true, 0, 0, 0));
controlListManager1.TargetList.Add(new ControlListManager.TargetSettings(this.restoreToolStripMenuItem, "", DisplayModes.FollowXY, true, 0, 0, 0));
controlListManager1.TargetList.Add(new ControlListManager.TargetSettings(this.exitToolStripMenuItem, "", DisplayModes.FollowXY, true, 0, 0, 0));
controlListManager1.TargetList.Add(new ControlListManager.TargetSettings(this.panel1, "", DisplayModes.FollowXY, true, 0, 0, 0));
controlListManager1.TargetList.Add(new ControlListManager.TargetSettings(this.IdentifierInput, "", DisplayModes.FollowXY, true, 0, 0, 0));
controlListManager1.TargetList.Add(new ControlListManager.TargetSettings(this.ExitButton, "", DisplayModes.FollowXY, true, 0, 0, 0));
controlListManager1.TargetList.Add(new ControlListManager.TargetSettings(this.IdentifierCheckbox, "", DisplayModes.FollowXY, true, 0, 0, 0));
controlListManager1.TargetList.Add(new ControlListManager.TargetSettings(this.SaveLogFile, "", DisplayModes.FollowXY, true, 0, 0, 0));
//...
问题是 SelectedIndex
应该在列表之后,因为它很好地代表了列表的索引。
如何告诉设计者将其放在列表之后?
因为我不想乱用 BeginInit() 和 EndInit() 方法(我真的应该这样做)并且发现,序列化程序顺序确实是按字母顺序排列的。
我将 SelectedIndex
重命名为 ZSelectedIndex
。有趣而肮脏 - 但快速解决方案。