millie_w

Hi guys,

How do I provide an icon to be displayed when my custom control is added to the toolbox with CF In the full version, its easy:

[ToolboxBitmap .... ]

but this seems to be missing in CF. Obviously it can be done, but having trawlled through here and MSDN, I cant find anything.

Thanks in advance,

Millie.



Re: .NET Compact Framework Toolbox Icon

MarcD

I believe the preferred method is to ensure that the bitmap is 16-bit or 8-bit, make sure it is an embedded resource. Set the ToolNamespace to something and then make sure there is a class in that namespace. Generally, it seems most developers call it ResLoader.

So something like namespace MyCompany.Resources { class ResLoader() { } }

then make sure the bitmap namespace is MyCompany.Resources and then when specifying the toolboxbitmap overload use the overload that takes a type.





Re: .NET Compact Framework Toolbox Icon

millie_w

MarcD,

thanks for the reply but my point is that ToolboxBitmap is NOT available in CF, so how is an icon used for the toolbox

Millie.





Re: .NET Compact Framework Toolbox Icon

Michael Koster

Add a design time data file (xmta) to your project and embed a bitmap to be used as the tooboxBitmap. Name the bitmap after your class name.

In the XMTA file add aTooboxBitmap tag:

Here is a short sample:

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

To test wheter this was successfull select 'Choose items...' in the toolbox and browse to your control assembly. Your control should be shown with the new bitmap.

Hope this helps
Michael






Re: .NET Compact Framework Toolbox Icon

millie_w

Michael,

Thanks for the reply, but your suggestion does not work.  Here is the top of mu xmta file:

< xml version="1.0" encoding="utf-16" >

<Classes xmlns="http://schemas.microsoft.com/VisualStudio/2004/03/SmartDevices/XMTA.xsd">

<Class Name="PersonPicker.Picker">

<DesktopCompatible>true</DesktopCompatible>

<Description>Pick a person from the list</Description>

<ToolboxBitmap>Picker.bmp</ToolboxBitmap>

| have tried all the different combinations for the bitmap filename but to no avail!!  It really MUST be quite simple, but how

Millie.

 





Re: .NET Compact Framework Toolbox Icon

Michael Koster

Hi Millie

All names (class Name, TooboxBitmap) must be fully qualified names (including all namespaces)

Check that the ''Picker.bmp' is properly included as an embedded resource in your project.
To get the proper name you have to specify in the XMTA file, use Reflector (Visual Studio prefixes the filename with the project default namespace).

Michael






Re: .NET Compact Framework Toolbox Icon

millie_w

First, thanks to all those who took the time to reply. Nice to know a girl can get an answer to a problem!!

The answer, like most things in life, was simple. Once you know how. Michael was right, well, nearly!! When I added the ToolboxBitMap element to the xmta file, it worked. But then it trashed all my Custon Attributes!! Removing the element restored the Custom Attributes but no bitmap.

Then I wondered why, in their wisdom, Microsoft would add an icon to a custom control. Afterall, this was not a program to have an icon displayed in it. Then the light came on!! Funny how we all seem to have these 'Ahhhhhhh....' moments, isn't it

So I edited the icon, made it an embedded resource and bingo!! it all worked! My Custom Attributes remained and all went home happy.

Millie.





Re: .NET Compact Framework Toolbox Icon

schoeni

Hello!

We are are currently trying the same thing, simply adding a toolbox item to a custom control. Therefore we added a xmta file.

<Class Name="Gulliver.CSharp.Controls.Forms.Button">
<ToolboxBitmap>Gulliver.CSharp.Controls.Forms.Button.bmp</ToolboxBitmap>
<DesktopCompatible>true</DesktopCompatible>
<Property Name="Grammar">

As you can see we specified the ToolboxBitmap attribute. Furthermore the icon is an embedded ressource. Examing the dll with Reflector the bitmap is included as ressource and has the correct name. Nonetheless it is never shown in the toolbox. We would be happy if you could describe what excatly you "Ahhhhhh" moment was

Thanks in advance

Hannes




Re: .NET Compact Framework Toolbox Icon

Michael Koster

Hi Hannes

Visual Studio automatically adds controls to the toolbox when a project containng controls. The problem is that this feature does not properly load and show the custom toolbox bitmaps.

Try the following:
- Load a device project and open a form.
-. Add a new Tab to the Toolbox (right click -> Add Tab)
- in this tab do right click -> choose item... the choose 'browse' and select your control DLL and hit OK

You should have your controls listed in the dialog.

Michael






Re: .NET Compact Framework Toolbox Icon

schoeni

Hi Michael!

I finnally succeded in adding the icon to the toolbox. As you mentioned I did rest the toolbar and manually added the items.

Another problem, which I am dealing with is adding a custom editor to a property.

I try to describe our specific situation:

We have an assembly containing our custom controls. Furthermore we have another assembly were the classes which represent our properties are stored. Furthermore we have an assembly were the Editor is implemented (derived from UITypeEditor). We created the properties in an own assembly due to the fact that we want to use Generics.

This is a part out of our xmta-File

<Class Name="Gulliver.CSharp.SpeechInput.SpeechInputGrammar">
<Editor>
<Type>Gulliver.CSharp.Controls.Design.GrammarPropertyEditor, Gulliver.CSharp.Controls.Design, Version=1.0.0.0, Culture=neutral, PublicKeyToken=18152bd0bc0c2cd2</Type>
<BaseType>System.Drawing.Design.UITypeEditor,System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a </BaseType>
</Editor>
<TypeConverter>
System.ComponentModel.ExpandableObjectConverter, System,
Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089
</TypeConverter>
<DesktopCompatible>true</DesktopCompatible>
<Property Name="GrammarName">
<Browsable>true</Browsable>
<DefaultValue>
<Type>System.String</Type>
<Value>name</Value>
</DefaultValue>
<Description>Identifies the grammar.</Description>
<NotifyParentProperty>true</NotifyParentProperty>
<DesignerSerializationVisibility>DesignerSerializationVisibility.Visible</DesignerSerializationVisibility>
</Property>
<Property Name="RootRule">
<Browsable>true</Browsable>
<Description>The grammar's root rule</Description>
<NotifyParentProperty>true</NotifyParentProperty>
<DesignerSerializationVisibility>DesignerSerializationVisibility.Visible</DesignerSerializationVisibility>
<DefaultValue>
<Type>Gulliver.CSharp.SpeechInput.Rule</Type>
<Value>null</Value>
</DefaultValue>
</Property>
</Class>
<Class Name="Gulliver.CSharp.Controls.Forms.Button">
<ToolboxBitmap>Gulliver.CSharp.Controls.Forms.Button.bmp</ToolboxBitmap>
<DesktopCompatible>true</DesktopCompatible>
<Property Name="Grammar">
<Browsable>true</Browsable>
<DesignerSerializationVisibility>DesignerSerializationVisibility.Visible</DesignerSerializationVisibility>
<Category>Speech</Category>
<Description>The button's grammar</Description>
<Editor>
<Type>Gulliver.CSharp.Controls.Design.GrammarPropertyEditor, Gulliver.CSharp.Controls.Design, Version=1.0.0.0, Culture=neutral, PublicKeyToken=18152bd0bc0c2cd2</Type>
<BaseType>System.Drawing.Design.UITypeEditor,System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a </BaseType>
</Editor>
<TypeConverter>
System.ComponentModel.ExpandableObjectConverter, System,
Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089
</TypeConverter>
</Property>
<Property Name="SpeechInput">
<Browsable>false</Browsable>
<DesignerSerializationVisibility>DesignerSerializationVisibility.Hidden</DesignerSerializationVisibility>
<Category>Speech</Category>
</Property>
<Property Name="Text">
<Browsable>true</Browsable>
<DesignerSerializationVisibility>DesignerSerializationVisibility.Visible</DesignerSerializationVisibility>
</Property>
</Class>

As I did not suceed in this situation, I tried to implement a simple demo project. When i used only two different assemblies (one for the control and the property classes, another one for the editor) i suceeded. As far is I know you have to sign the projects and put the editor into the GAC. Following these instructions the editor was displayed but splitting up the controls and its properties into two different assemblies did not work.

Maybe you can help me with this specific problem.

Thanks in advance

Hannes