Programing

도구 상자에 표시되지 않는 사용자 컨트롤

lottogame 2020. 10. 26. 07:37
반응형

도구 상자에 표시되지 않는 사용자 컨트롤


ProjectA에서 만든 UserControls가 있습니다. 컨트롤을 추가하려는 Windows 폼이있는 ProjectB가 있습니다. 이 두 프로젝트는 모두 단일 솔루션에 있습니다. ProjectB에서 ProjectA에 대한 참조가 있으므로 UserControls를 "볼"수 있습니다.

그러나 UserControls는 도구 상자에 표시되지 않아 Windows 폼으로 끌 수 있습니다.

재건을 시도했습니다. 또한 강제로 모두 다시 빌드하기 위해 'bin'디렉토리를 삭제했습니다.

내 UserControls로 도구 상자를 채우도록 VS2008을 얻으려면 어떻게해야합니까?


이 설정을 확인하십시오.

도구> 옵션> Windows Forms 디자이너> 일반 : AutoToolboxPopulate

이 작업을 수행하려면 True로 설정해야합니다.


  1. 프로젝트를 빌드하여 컴파일되는지 확인하십시오.

  2. 사용자 제어를 원하는 양식으로 도구 상자를 열고 마우스 오른쪽 단추를 클릭 한 다음 "항목 선택"을 선택하십시오.

  3. 1 단계에서 컴파일 한 .exe 또는 dll을 찾습니다.

  4. 사용자 컨트롤 옆에 체크 표시가 있는지 확인하고 확인을 누릅니다.

  5. 사용자 정의 컨트롤이 도구 상자에 나타나야하므로 양식으로 드래그하십시오.

이것은 비슷한 질문에 대한 Calanus의 답변 에서 채택되었습니다 .


제 경우에는 AutoToolboxPopulate가 이미 설정되어 있습니다 (Visual C # 2010 Express).

그러나 실제로 새 사용자 컨트롤을 보려면 도구 상자의 속성에서 "모두 표시"를 활성화해야했습니다 (오른쪽 클릭).


지금까지는 도구 상자에 표시되지 않는 사용자 컨트롤에 문제가 없었습니다. 프로젝트를 빌드하면 나타납니다. 그렇다면 오늘은 작동하지 않습니다. 수색 후 나는 따라 갔지만 여전히 기쁨이 없습니다.

  • 도구> 옵션> Windows Forms 디자이너> 일반 : AutoToolboxPopulate
  • 도구> 옵션> 텍스트 편집기> XMAL> 기타 : AutoToolboxPopulate
  • VS 설정을 기본값으로 재설정

그래서 성공하지 못한 채 작동하도록 몇 시간을 엉망으로 만든 후 기본 이름을 수락하는 새로운 WPF Windows 프로젝트를 만들고 사용자 컨트롤을 추가했습니다. 프로젝트를 구축하고 사용자 컨트롤은 항상 그랬던 것처럼 보였습니다.

그런 다음 내 프로젝트 또는 wpf 창 파일에 문제가 있다고 생각했습니다. 프로젝트를 제거하고 새 프로젝트를 만들고 새 컨트롤을 추가했습니다. 프로젝트를 만들었지 만 작동하지 않았습니다.

내가 한 유일한 일은 프로젝트의 이름을 선택하는 것이었고 "WPF Application"이라는 이름에 공백을 포함 시켰습니다.

프로젝트를 다시 제거하고 공백없이 "WPFApplication"이라는 새 프로젝트를 만들고 사용자 정의 컨트롤을 추가했습니다. 그것을 구축하고 사용자 컨트롤이 나타났습니다.

사용자 컨트롤이 빌드시 도구 상자에 자동으로 표시되도록하려면 프로젝트 이름에 공백을 사용하지 마십시오. 이 게시물이 다른 사람에게 많은 시간을 낭비하기를 바랍니다.


사용자 컨트롤이 도구 상자에 표시되지 않는 또 다른 이유는 기본 생성자가없는 경우입니다.


또한 사용자 컨트롤에 유효한 네임 스페이스가 있는지 다시 확인하십시오.

네임 스페이스가없는 컨트롤은 ToolBox 내부에 배치되지 않습니다.


일반적으로 솔루션을 빌드해야합니다. 거의 항상 저에게 효과적입니다.


나는 같은 문제가 있었다. 인터넷 검색을 많이 한 후 아무것도 찾지 못했지만 우연히 사용자 컨트롤을 만든 동일한 프로젝트에있는 동안 도구 상자를 클릭하고 " 모두 표시 "를 선택한 다음 그룹 사용자 컨트롤을 찾을 수있는 도구 상자의 맨 위에 프로젝트와 동일한 이름이 표시됩니다. 이제 원하는 양식에 컨트롤을 추가 할 수 있습니다!


작업 할 수있는 사람 ToolStripItems(예를 들어 ToolStripStatusLabel실제로 드롭 다운 메뉴에 표시하기 위해 파생 된 제어를 얻을), (예에서 하나 StatusStrip), 당신은에 클래스를 설정해야public 다음 솔루션을 구축 할 수 있습니다.

또한 다음과 같이 클래스의 디자이너 속성을 잊지 마십시오.

using System.Windows.Forms.Design;

[ToolStripItemDesignerAvailability(ToolStripItemDesignerAvailability.StatusStrip)]
public class MyStatusLabel : ToolStripStatusLabel
{
}

제대로하는 데 시간이 좀 걸렸습니다. 다른 사람의 시간을 절약 할 수 있기를 바랍니다.


내 컨트롤이 공개되어 '도구 상자 항목 선택'대화 상자에서 확인되었지만 여전히 표시되지 않았습니다.

이것이 마침내 나를 위해 일한 것입니다.

도구 상자의 아무 곳이나 마우스 오른쪽 버튼으로 클릭하고 '항목 선택'을 클릭하십시오. 내 항목을 찾았을 때 이미 확인되었습니다. 그런 다음 항목을 선택 취소하고 확인을 클릭했습니다. 그런 다음 도구 상자를 다시 마우스 오른쪽 버튼으로 클릭하고 내 항목을 검색했습니다. 사라 졌으므로 찾아보기를 클릭하고 obj / x86 / debug 폴더로 이동 한 다음 내 exe를 선택했습니다. 그런 다음 항목이 도구 상자에 올바르게 추가되었습니다.

VS 버그라고 생각합니다.


제공된 모든 지침 (Tools> Options> Windows Forms Designer> General : AutoToolboxPopulate)을 제외하고 + 솔루션을 빌드해야합니다 (나에게 분명함). 아마도 클래스 액세스 한정자에주의를 기울여야 할 것입니다. 공공의. 방금 컨트롤을 만들고 도구 상자 목록에 나타나지 않았고 그 이유를 알지 못했습니다. 그래서 설정 후

public class  yourClass:control {}

목록에 나타난 것보다. ;) 이것이 다른 사람들을 도울 수 있기를 바랍니다.


빌드 출력 디렉토리를 확인하십시오. 어떤 이유로 프로젝트 bin \ 디렉터리가 아닌 다른 위치에 출력을 빌드하는 경우 도구 상자에 컨트롤이 표시되지 않습니다.


내 문제는 다음과 같습니다. 몇 가지 인수를 허용하는 새 생성자를 컨트롤에 추가했지만 빈 생성자를 명시 적으로 다시 선언하지 않았습니다! 도구 상자에는 생성자가 비어있는 컨트롤 만 포함될 수 있습니다. 일반적으로 vb에서 클래스를 디자인 할 때 암시 적으로 정의 된 빈 생성자가 있습니다 (즉, 선언 할 필요가 없음). 하지만 생성자를 직접 디자인하기 시작하면이 빈 생성자가 사라 지므로 코드에서 명시 적으로 다시 정의해야합니다! 어쨌든, 나는 가장 경험이 많은 VB 코더가 이미이 모든 것을 알고 있다는 것을 알고 있지만, 이것이 저와 같은 일부 초보자를 도울 수 있기를 바랍니다. :).


위의 모든 사항이 실패 할 수 있습니다.

새 사용자 정의 컨트롤 (TestControl)을 만들어 수정했고 Visual Studio를 트리거하여 프로젝트의 컨트롤 탭 + 컨트롤을 도구 상자에 다시 추가했습니다. 그런 다음 테스트 컨트롤을 삭제했습니다.

그건 그렇고 최근에 VS 2008 자동 Windows 업데이트를 설치 한 후 나에게 일어났습니다.


내가 일반적으로하는 일은 새 탭을 만들고 해당 탭에 exe / dll을 추가하는 것입니다.로드 시간과 일반적인 번거 로움으로 인해 해당 솔루션에 너무 익숙하지 않습니다.

친구가이 속도를 높이는 방법을 보여주었습니다. 도구 상자 등에서 "항목 선택 ..."을 클릭 할 필요없이 새 컨트롤을 만들 때마다-이름이 지정된 파일을 만들 수 MyCustomControls있으며 여기에서 사용자 지정 컨트롤을 만들 수 있습니다.

이제 "항목 선택 ..."을 수행하고이 파일을 한 번만 추가하면됩니다. 나중에 새 컨트롤을 추가하기로 결정한 경우에서 MyCustomControls만든 다음 다시 빌드하십시오.
그러면 도구 상자에 새로운 컨트롤이 생깁니다. ( AutoToolboxPopulate내 생각에 정규 컴파일로 자동 표시됩니다 )

이는 종종 클래스를 "파일 당 하나의 클래스"로 분리하기를 원하기 때문에 불행한 일입니다. VS가 당신의 방식으로 그것을 원하지 않기 때문에 코드 아키텍처를 망쳐 야한다는 것은 끔찍합니다. :)

저도이 솔루션에 너무 익숙하지 않지만 빠르게 작업해야하고 파일 내에서 여러 사용자 컨트롤에 신경 쓰지 않거나 게으른 경우 적합 할 수 있습니다. :)


글쎄, 이것이 효과가 있다는 것을 제외하고는 아무것도 나를 위해 일하지 않았습니다 ...

  1. I create a new project in my solution, and for this project it works so I was going to start using this one
  2. Playing arond, I started tweaking the xml of the csproj file to find out what was wrong with my other project in the same solution and then I reset it as it didn't seem to be working
  3. It is now magically working again in my project

Not a very good solution but you should try these steps

  1. See if it works in a brand new solution/project.
  2. See if it works in a brand new project in the same solution
  3. If #2 worked, maybe compare .csproj files...somehow mine started working again while I was doing this(this is very frustrating).

Providing you already tried tinkering with:

  • Tools > Options > Windows Forms Designer > General : AutoToolboxPopulate
  • Tools > Options > Text Editor > XMAL > Misc : AutoToolboxPopulate
  • created a default constructor
  • build your project / reset the toolbox and add manually your tab

Yet you still see it greyed out..

Check your path length and check the charcters being used in your absolute path.

I had a project residing in "C:\Users\myName\myCompany\R&D\Projects"
And after few hours found out that the "R&D" is the problem..
The '&' did not allow my usercontrol items to be enabled in my toolbox.


I fell into this trap just a couple of hours ago.
I've got a .NET 2.0 Windows Application project with some custom UserControls; it worked fine. So I decided to order my files in subfolders, to make my project a little bit cleaner.
After that, Visual Studio 2010 designer stopped loading my forms, and ToolBox won't show my controls anymore.
I freaked out, moving back source files in project root, resetting ToolBox, but nothing seemed to work. After that, I remembered I used ReSharper "Remove Unused References", so I tried to put back unused reference, in particular System.Data: problem solved! :O I can't say you why, but this worked for me.
Hope my experience can help someone else. :)
Bye, Nando


If you still can't find why your vstudio toolbox is not populated with your usercontrols. Then you can debug vstudio with another visual studio. Here you can find how.


If you've tried following all the other answers and it still doesn't work, the following fixed it for me:

  • Right click on your project containing your control.
  • Select Properties.
  • In the Build settings category, make sure Register for COM interop is checked.

In my case the reason of error was an excess length of a path to my control's .dll. I had shrunk it a bit and everything became working fine.

Also I found out that the special symbols (e.g. I used #) in a path affect a control display.

Hope it solves the issue.


In your UserControl, make sure that New is declared Public. It won't show up if it's just declared Sub New (which defaults to Friend).


Symptom 1: The Design Views for Form, UserControl, & Component were FAILING!

  • My Form design view was failing w/ the msg "can not find 'User Control'."
  • If I could get the Form design view to work it was very unstable & corrupted all to hell w/ any change.

Symptom 2: The UserControl & Component in the Toolbox

  • Were grayed out in the Toolbox & showed a garbled name
  • "Choose item" in the Toolbox context menu showed garbled name & no namespace

Solution: Set scope to Public in the vb behind UserControl, & Component


Check project path, avoid & , # etc.

I've moved my solution from drive:\work\c#\folder\ to drive:\work\folder and it solved the problem.


I was trying to build a x64 only application, so my platform target was set to x64 of course.

However, even in 2016, Visual Studio (devenv.exe) is still a 32 bit process and it cannot load 64 bit assemblies. To check the bitness of your Visual Studio, open Task Manager and check for *32 at the name of the process.

Workaround to see the Controls in the toolbox: set the platform target to Any CPU in the project settings. Do that for Debug and Release build, if necessary.


When I tried to add my UserControl to the toolbox (right click toolbox, choose items, select my DLL) it would display a message saying there were no controls in my DLL.

Anyway, the problem was solved, by trying to create a form in my DLL in VS and adding the UserControl. An error message displayed saying there was no default constructor

public UserControl() {
...
}

The designer needs this because it can't know what valid arguments are. Once I added a blank constructor to the UserControl it was added to the toolbox without issue.


As mentioned here you should tell the visual studio to load your usercontrol in toolbox.

[ToolboxItem(true)]
public class PanelTitle : LabelControl  {
// Whatever code to override LabelControl here...
}

Before trying to add a custom control, make sure that it is compatible with the .Net version of your current project.

I was trying to add a custom control to toolbox for a project for Windows CE 5.0 and .Net Compact v3.5 on VS2008. I did all those previous suggestions but nothing worked. The control shows up when "show all" is checked but it is grayed , even in "Choose Items" menu is checked.

I created a new project with .Net v2.0 and it worked perfectly.


hello its answer Ctrl+Alt+X take this and later u have TOOLBOX :)

참고URL : https://stackoverflow.com/questions/288047/user-controls-not-showing-up-in-the-toolbox

반응형