【问题标题】:Can no longer edit control from Visual Studio Design View无法再从 Visual Studio 设计视图编辑控件
【发布时间】:2012-09-17 15:17:22
【问题描述】:

我正在开发一个控件,并且一直在从 VS 设计视图编辑它的视图。我没有编辑 Designer.cs 文件,只有 .cs 文件。但是,突然之间(星期一)我再也看不到设计视图中的控件了。什么会导致这种情况发生?我该如何解决?

编辑:这是我尝试过的。我读到,对于用户控件this.DesignMode 将始终为假,因此应该像我在这里所做的那样在 Load 事件中检查它,但我仍然无法使用设计视图。想法?

            this.Load += (sender, args) =>
                         {
                             if (this.DesignMode)
                                 return;

                             try
                             {
                                 DateTime timeWhenLoaded = DateTime.Now;
                                 this.LoadLayouts();
                                 this.LoadScheduleView(timeWhenLoaded);
                             }
                             catch (Exception ex)
                             {
                                 log.Warn("Something went wrong while setting up the Layout Scheduler", ex);
                             }
                             finally
                             {
                                 this.FormIsOpening = false;
                             }
                         };

【问题讨论】:

  • Error List Visual Studio 窗口中是否出现任何错误?
  • 您可能将代码添加到构造函数或初始化或引发异常的 Load 事件。如果您的表单处于设计模式,您会签入代码吗?
  • @rene 不,我试试看!
  • @rene 如果我发现它正在设计视图中加载,我到底应该做什么/禁止?
  • 我用更多信息更新了原帖@rene

标签: c# .net visual-studio-2010 visual-studio


【解决方案1】:

这个特殊的控件有一个DataGridView,它使用一个特殊的扩展类来创建一个CalendarColumn。这是一个内部类。为了便于阅读,我将这个内部类放在了一个区域,位于正在设计的类的声明之上。一旦我将它移回到正在设计的类的声明下方,设计器就会立即弹出查看!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多