简体   繁体   English

如何获取用户控件进行更新

[英]how to get usercontrol to update

This is in MSVC# 2008. I wrote a simple usercontrol that has 2 labels, 2 textboxes and 1 button. 这是在MSVC#2008中。我编写了一个简单的usercontrol,它具有2个标签,2个文本框和1个按钮。 I also created a few properties for the user to set the labels' and the button's text. 我还为用户创建了一些属性来设置标签和按钮的文本。

I added this usercontrol to a form, compiled and ran it and it worked fine. 我将此用户控件添加到窗体中,编译并运行它,并且效果很好。 Then today I went back and added another similar property. 然后今天我回去并添加了另一个类似的属性。 Now suddenly the new one wouldn't get recognized when I tried to set it. 现在突然间,当我尝试设置它时,新的就不会被认可。 I was curious, so I tried to comment out one of the old properties, rebuilt everything again, and I still saw the supposedly "deleted" property showing up in the list. 我很好奇,所以我尝试注释掉其中一个旧属性,然后再次重建所有内容,但仍然看到列表中显示了所谓的“已删除”属性。

What is going on? 到底是怎么回事? What must I do to get it to "update" when rebuilding doesn't? 不重建时我该怎么做才能使其“更新”? If you need to see the code please let me know. 如果您需要查看代码,请告诉我。

EDIT: Thank you all for replying. 编辑:谢谢大家的答复。 I apologize for not having mentioned that they do have separate assemblies. 对于没有提到它们确实具有单独的程序集,我深表歉意。

Sometimes VS gets a bit buggy with WinForm controls and my guess this is what happened to you. 有时VS在使用WinForm控件时会遇到一些错误,我想这就是发生在您身上的事情。 Try: 尝试:

  1. Run clean on the solution, restart VS, build everything and see if it helped 运行该解决方案,重新启动VS,构建所有内容,看看是否有帮助
  2. If not, close VS, delete the .suo file, start VS, clean, rebuild 如果不是,请关闭VS,删除.suo文件,启动VS,清理并重建

Let me know if it doesn't help 让我知道是否有帮助

If you have placed the User Control in separate assembly, then it looks like the project dependencies are not set up correctly (Solution, properties). 如果将用户控件放置在单独的程序集中,则看起来项目依赖关系未正确设置(解决方案,属性)。 Check the timestamp of the DLL in the FormsProject\\bin\\Debug folder. 检查FormsProject \\ bin \\ Debug文件夹中DLL的时间戳。

If this happen in 1 Project, it is certainly strange. 如果这在1项目中发生,那肯定是奇怪的。 Normally a (Re)Build should be enough. 通常,(重新)构建应该足够。 Can you build w/o errors? 您可以建立无错误的工具吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM