SharpDevelop Community

Get your problems solved!
Welcome to SharpDevelop Community Sign in | Join | Help
in Search

Include my Form to form templates

Last post 08-25-2017 7:47 PM by sbridewell. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 08-24-2017 5:39 PM

    Include my Form to form templates

    Hi!

    I want to create my own form inherited by System.Windows.Forms.Form and this to appeare on the list, Add->New Item->[WindowsApplication]Form.

    And ofcourse to be editable on the designer..

    Thank you!

    Filed under:
  • 08-25-2017 7:47 PM In reply to

    Re: Include my Form to form templates

    First you need to locate the folder where all the templates are stored. Start from your SharpDevelop installation folder (something like C:\Program Files (x86)\SharpDevelop\5.2).

    Go into the data subfolder, and then the templates subfolder. This has two subfolders - file and project. As you'll be creating a form template, go into the file subfolder. Choose the most appropriate subfolder for this for the template you're creating (probably CSharp or VB depending on the language you're using).

    Assuming you're using C#, take a copy of CSharp.Forms.Form.xft and use this as the starting point for your form template.

    You'll see that this template is an XML document with two <File> elements, one of which is the main form class and the other is the form's .designer file with the designer generated code, and the innertext of each of these elements is the initial content of a file created from your template.

    Anywhere that you see something similar to ${TokenName}, this is a token which SharpDevelop will replace with some value when you create a file from the template. Some of these values come from information you enter into the new file dialogue and some of them come from application resources (e.g. ${StandardHeader.C#} gets whatever text you've set in tools -> options -> coding -> edit standard headers). Most of these you won't need to change, but a useful one is ${ClassName}, which you can use anywhere in your code where you want the name of the class to appear.

    Also, have a look at the <Config> element at the top of the template. This controls how your template appears in the new file dialogue. As a minimum you ought to change its name attribute to whatever name you want to give to your template.

    Add whatever code you want to the form class and/or the .designer file, save the template, and it should now be available to you to use in the new file dialogue. And if your class is derived from Form or UserControl then it should be editable in the designer, provided you haven't done anything which prevents the designer from creating an instance of the class (e.g. be sure it has a parameterless constructor).

    There are quite a lot of templates already implemented, so you should be able to get a good idea of what can be done by looking at them.

    Good luck :-)

    Simon.

Page 1 of 1 (2 items)
Powered by Community Server (Commercial Edition), by Telligent Systems
Don't contact us via this (fleischfalle@alphasierrapapa.com) email address.