사용자 정의 컨트롤을 추가 할 수 없음 "도구 상자 항목을로드하지 못했습니다"C # winforms

심구

응용 프로그램에서 작업 할 때 해당 프로젝트에 대한 첫 번째 사용자 컨트롤을 추가하기로 결정했습니다. 나는 그것을 잘 만들었지 만 도구 상자에서 기본 양식으로 드래그하면 오류 메시지가 나타납니다.

여기에 이미지 설명 입력

내가 무엇을하든 그것을 고치지 않는 것 같습니다. 코드를 통해 추가해 보았지만 전혀 나타나지 않을 것입니다.

온라인으로 문제를 살펴보면서 나는 작동하는 해결책을 찾을 수 없었거나 적어도 내가 따르고 이해할 수있는 해결책을 찾지 못했습니다.

도움을 주시면 감사하겠습니다. 더 많은 정보가 필요하면 추가해 드리겠습니다. 그러나 현재 나는 어떤 용도로든 추가 할 수있는 것이 무엇인지 모르겠습니다.

이 코드는 단순한 장난 바이러스를위한 것입니다. (계속해서 코드를 배우도록 영감을주세요 :)) 여기에 코드가 있습니다 ( 파일을 실행하지 마십시오. 결국 장난 바이러스입니다. 종료하는 유일한 방법은 alt +입니다. f4 ) :

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Imaging;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Simple_virus_V2
{
    public partial class Form1 : Form
    {
        [DllImport("user32.dll")]
        internal static extern IntPtr SetForegroundWindow(IntPtr hWnd);

        [DllImport("user32.dll")]
        internal static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);

        public Form1()
        {
            InitializeComponent();
            timer1.Start();
            timer2.Start();

            
            Thread newthread = new Thread(progress);
            newthread.Start();
        }
        Random rnd = new Random();
        int noticewidth = 0;
        bool changecursor = false;
        
        private void progress() {

            Thread.Sleep(1000);
            changecursor = true;
            Thread.Sleep(1000);
            timer3.Start();
            Thread.Sleep(5000);
            noticewidth = Width;

        }
        int mouseflash = 0;
        private void timer1_Tick(object sender, EventArgs e)
        {
            if (changecursor) {

                if (mouseflash < 1000)
                {
                    Bitmap cursor = new Bitmap(new Bitmap(pictureBox1.Image), 24, 24);
                    Cursor = new Cursor(cursor.GetHicon());
                
                
                } else if (mouseflash < 1700) {

                    Bitmap cursor = new Bitmap(new Bitmap(pictureBox2.Image), 30, 30);
                    Cursor = new Cursor(cursor.GetHicon());

                }
                else {

                    mouseflash = 0;
                }


                mouseflash = mouseflash + rnd.Next(3,10);
            }
            header.Left = MousePosition.X - (header.Width / 2);
            label2.Left = MousePosition.X - (label2.Width / 2);
            label3.Left = label2.Left + 25;

            panel1.Width = noticewidth;
            this.Location = new Point(0,0);
            panel1.Location = new Point(0, MousePosition.Y - 40);
            this.WindowState = FormWindowState.Maximized;
            TopMost = true;
            
            Process currentProcess = Process.GetCurrentProcess();
            IntPtr hWnd = currentProcess.MainWindowHandle;
            if (hWnd != IntPtr.Zero)
            {
                SetForegroundWindow(hWnd);
                ShowWindow(hWnd, int.Parse("9"));
            }
            
            Focus();
            this.Width = Screen.PrimaryScreen.Bounds.Width * 3;
            this.Height = Screen.PrimaryScreen.Bounds.Height * 2; 
            
        }

        private void Form1_KeyPress(object sender, KeyPressEventArgs e)
        {

            
            
        }

        private void Form1_FormClosing(object sender, FormClosingEventArgs e)
        {
            /*
            using (Form1 frm = new Form1()) {
                if (frm.ShowDialog() == DialogResult.OK) {

                }
            }
            */
        }

        private void timer2_Tick(object sender, EventArgs e)
        {
            
            
            PictureBox pic = new PictureBox();
            pic.Width = 1;
            pic.Height = 1;
            pic.BackColor = Color.Black;
            pic.Location = new Point(rnd.Next(0, this.Width), rnd.Next(0, this.Height));
            this.Controls.Add(pic);
            

        }

        private void timer3_Tick(object sender, EventArgs e)
        {
            /*
            bartry bars = new bartry();
            bars.Location = new Point(0, rnd.Next(0, 500));
            Controls.Add(bars);


            timer3.Interval = rnd.Next(100, 5000);
            */
        }
    }
}

감사

심구

다른 게시물에 대한 답변을 시도한 후에도 아무도 작동하지 않았습니다. 새 프로젝트를 열고 내 코드를 실험 한 후에 해결책을 찾았습니다.

해결 방법 : 사용자 정의 컨트롤과 기본 양식에 동일한 "사용"참조가 있는지 확인하십시오!

이게 자명하다면 미안하지만 그렇게해야한다는 것을 몰랐습니다.

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

TOP 리스트

  1. 1

    Ionic 2 로더가 적시에 표시되지 않음

  2. 2

    JSoup javax.net.ssl.SSLHandshakeException : <url>과 일치하는 주체 대체 DNS 이름이 없습니다.

  3. 3

    std :: regex의 일관성없는 동작

  4. 4

    Xcode10 유효성 검사 : 이미지에 투명성이 없지만 여전히 수락되지 않습니까?

  5. 5

    java.lang.UnsatisfiedLinkError : 지정된 모듈을 찾을 수 없습니다

  6. 6

    rclone으로 원격 디렉토리의 모든 파일을 삭제하는 방법은 무엇입니까?

  7. 7

    상황에 맞는 메뉴 색상

  8. 8

    SMTPException : 전송 연결에서 데이터를 읽을 수 없음 : net_io_connectionclosed

  9. 9

    정점 셰이더에서 카메라에서 개체까지의 XY 거리

  10. 10

    Windows cmd를 통해 Anaconda 환경에서 Python 스크립트 실행

  11. 11

    다음 컨트롤이 추가되었지만 사용할 수 없습니다.

  12. 12

    C #에서 'System.DBNull'형식의 개체를 'System.String'형식으로 캐스팅 할 수 없습니다.

  13. 13

    JNDI를 사용하여 Spring Boot에서 다중 데이터 소스 구성

  14. 14

    Cassandra에서 버전이 지정된 계층의 효율적인 모델링

  15. 15

    복사 / 붙여 넣기 비활성화

  16. 16

    Android Kotlin은 다른 활동에서 함수를 호출합니다.

  17. 17

    Google Play Console에서 '예기치 않은 오류가 발생했습니다. 나중에 다시 시도해주세요. (7100000)'오류를 수정하는 방법은 무엇입니까?

  18. 18

    SQL Server-현명한 데이터 문제 받기

  19. 19

    Seaborn에서 축 제목 숨기기

  20. 20

    ArrayBufferLike의 typescript 정의의 깊은 의미

  21. 21

    Kubernetes Horizontal Pod Autoscaler (HPA) 테스트

뜨겁다태그

보관