开发者

C# Creating a custom control

开发者 https://www.devze.com 2023-01-22 18:48 出处:网络
I need help creating a .dll file from a custom control so that it can be used on other projects. This is the first time I am doing this, and I couldn\'t find much help via google so help would be much

I need help creating a .dll file from a custom control so that it can be used on other projects. This is the first time I am doing this, and I couldn't find much help via google so help would be much appreciated.

I have this code and I know 开发者_如何学编程I have to compile it as a class project, but I really don't know how, so I'd appreciate it if someone can guide me how I would do that.


All you have to do is create a new Class Library project, then paste your code into a class file. Then compile.

You can reference the resulting DLL from other projects.

Here's a tutorial.


I think it's simply a matter of changing your output type to Class Library in the Application tab of your project's properties.


Start a new Windows Forms project. Project + Add Reference, select Microsoft.VisualBasic. Project + Add New Item, select Class. Delete what's there then paste the code. Compile. Drop the new control from the top of the toolbox onto the form.

There's a bug in the code, you'll get the drives displayed twice when you press F5. Alter the code and make it look like this:

    public FileExplorer() {
        this.BeforeExpand += customBeforeExpand;
        // CreateTree(this);    // <== delete this line
    }

    protected override void OnHandleCreated(EventArgs e) {
        base.OnHandleCreated(e);
        if (!DesignMode) CreateTree(this);
    }
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号