当我在 Visual Studio(设计器视图)中重建时,我的 userControl 中的更改被删除 [英] Changes in my userControl are erased when I rebuild in Visual Studio (designer view)
问题描述
This is my navigationItem.cs user control:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Uboldi.Helpers;
namespace Uboldi
{
public partial class NavigationItem : UserControl
{
public bool IsSelected { get; set; }
private string _linkText = String.Empty;
[Browsable(true)]
public string LinkText
{
get { return this._linkText; }
set
{
this._linkText = value;
RefreshDisplay();
}
}
public NavigationItem()
{
InitializeComponent();
RefreshDisplay();
}
private void RefreshDisplay()
{
if (IsSelected)
this.BackColor = CustomizationHelper.GetSecondaryColor();
else
this.BackColor = CustomizationHelper.GetPrimaryColor();
lblText.Text = Text;
}
}
}
我的目的是在另一个名为 NavigationBar 的用户控件中使用它.
My intention is to use this in another usercontrol called NavigationBar.
虽然我可以看到 NavigationItem.cs 类的 LinkText 属性,但当我从属性窗格更改它时,会弹出警告:
While I CAN see the LinkText attribute of the NavigationItem.cs class, when I change it from the properties pane, a warning pops up:
警告 1 您必须重建您的项目变更Uboldi.LeftNavigationbar 出现在任何开放的设计师.
Warning 1 You must rebuild your project for the changes to Uboldi.LeftNavigationbar to show up in any open designers.
公平,我重建,然后我刚刚输入的更改消失了!
Fair enough, I rebuild, and then the changes I just typed in are gone!
知道为什么吗?
感谢您抽出宝贵时间.
推荐答案
这是旧的,但没有答案.这是我发现有效的方法.希望这对其他人有所帮助.
This is old but doesn't have an answer. Here is what I found that works. Hopefully this helps someone else.
[Browsable(true)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
[Description("Test text displayed in the link"), Category("Data")]
public string LinkText
{
get { return this._linkText; }
set
{
this._linkText = value;
RefreshDisplay();
}
}
这篇关于当我在 Visual Studio(设计器视图)中重建时,我的 userControl 中的更改被删除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!