locked
How to set Custom Control Toolbox icon from existing control? RRS feed

  • Question

  • I have created a new custom control deriving from System.Windows.Forms.Control.  I would like to give it the same toolbox icon as that from TextBox.  How do I do it?

    Saturday, October 27, 2007 12:37 AM

All replies

  • Hi jrh7000,

    Please look at this issue, Michael gives the detail steps:

     

    Add a design time data file (xmta) to your project and embed a bitmap to be used as the tooboxBitmap. In the XMTA file add aTooboxBitmap tag.

    In the XMTA file add aTooboxBitmap tag:

    Here is a short sample:

    Code Block

    <?xml version="1.0" encoding="utf-16"?>
    <
    Classes xmlns="http://schemas.microsoft.com/VisualStudio/2004/03/SmartDevices/XMTA.xsd">
      <
    Class Name ="Your project">
        <
    DesktopCompatible>true</DesktopCompatible>
        <
    Description>Label mit Border</Description>
        <
    ToolboxBitmap>youricon.gif</ToolboxBitmap>
      </Class>
    </
    Classes>

     

     

    Best regards,

    Guang-Ming Bian - MSFT

     

     

    Tuesday, October 30, 2007 8:37 AM
  • This works fine for defining your own icons.  However I want to use the System.Windows.Forms.TextBox icon.  I know this is possible on the full framework using the ToolBoxBitmap attribute.  Is this possible for Smart Device projects?

    Tuesday, October 30, 2007 11:32 PM
  • Hi jrh7000,

    You can search the textbox icon in your vs2005 folder and take it as your own icon, it will works fine.

    Compact framework doesn't support ToolBoxBitmap atribute.

     

    Best regards,

    Guang-Ming Bian - MSFT

    Wednesday, October 31, 2007 5:14 AM
  • I tried searching my "Microsoft Visual Studio 8" directory for icons but there were none for the TextBox.

     

    I realise that the Compact Framework does not support the ToolBoxBitmap attribute.  There are a lot of design time attributes that are not supported but the XTMA file does support most of them.  It uses a different syntax which is fine.  I was hoping that the ToolBoxBitmap could handle the following:

     

    Code Block

    <?xml version="1.0" encoding="utf-16"?>
    <
    Classes xmlns="http://schemas.microsoft.com/VisualStudio/2004/03/SmartDevices/XMTA.xsd">
      <
    Class Name ="MyTextBox">
        <
    ToolboxBitmap>

          <Type>System.Windows.Forms.TextBox, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</Type>

        </ToolboxBitmap>
      </Class>
    </
    Classes>

     

     

     

    Is there a variation that would work?

    Wednesday, October 31, 2007 5:41 AM