1

Visual Studio 2008 では、コントロールを検出してプロジェクトからツールボックスに追加し、フォーム デザイナで使用できるようになりました。UserControl 派生型または DataSet 派生型のアセンブリがある場合は、そのコントロールが自動的に検出され、フォームをデザインするためのツールボックスに追加されます。これは、2005 年に手動でコントロールを追加し、時々それらを忘れていた古いシステムよりもわずかに優れています。

However, on the legacy, monolithic project I am working on (now upgraded to vs2008) this means many controls that I don't want and don't need (and a redesign would not be warranted against so much legacy code :( ). I imagine that if I made certain types internal or private, then they wouldn't show up. However, I need many of those to remain public, but not show up in the toolbox. Furthermore, with so many controls getting added to the toolbox, opening the winforms designer slows significantly.

  1. Is there an attribute or other mechanism that prevents toolbox appearance (that wouldn't otherwise affect functionality) ?
  2. Would filtering using such a mechanism improve performance while still autodetecting new types that SHOULD be in the toolbox? (I know you can disable the autodetect, but its nice to have in many cases)
  3. Have others encountered this irritation on large solutions (with many csproj/vbproj files)?

Edit: Thanks everyone! I knew it had to be simple (and was likely an attribute) but that fills the gap. Nice to know that I was in good company in not knowing about ToolBoxItem(false).

4

2 に答える 2

2

次の属性は、ツールボックスから非表示にする必要があります。

[ToolboxItem(false)]

表示したくないすべてのタイプに適用すると、この属性なしで作成した新しいタイプが表示されます。最初にアイテムを手動で削除する必要がある場合があることに注意してください。

このブログ投稿では、使用できるその他の属性をいくつか示しています。

于 2009-01-19T22:47:01.043 に答える
1

ツールボックスを調べて、非表示にするカスタム コントロールごとに、クラスの上に次の属性を追加します。

[ToolboxItem(false)]

もちろん、これはコンパイル済みの属性であり、コードを使用するすべての人に影響するため、ドラッグ アンド ドロップの意味をなさないコントロールに対してのみこれを行うことをお勧めします。そうしないと、おそらくそのコントロールを愛する人を非常に怒らせるでしょう. :)

于 2009-01-19T22:45:29.690 に答える