Версия для печати темы
Нажмите сюда для просмотра этой темы в оригинальном формате
Форум программистов > Разработка Windows Forms > ToolboxBitmap


Автор: Bogdan1024 20.4.2009, 23:11
Теоретически есть 2 способа замутить для своего контрола картинку. 
Первый: прописать путь к картинке в аттрибуте ToolboxBitmap.
Второй: создать картинку с названием файла таким же как и класс и пометить её билд экшн в проджэкт экплорере как эмбэдд рисорс. 
Второй способ у меня не работает. Почему?

Автор: Ctrl 21.4.2009, 19:35
Второй способ справедлив только для WPF элементов, да и то надо использовать имя вида <ControlClassName>.Icon.<ext>

Добавлено через 3 минуты и 56 секунд
ой, сорри вот вроде так тоже можно

Цитата

...
Use a bitmap (not an icon, in the embedded resource) file implicitly without specifying the ToolboxBitmapAttribute for the type:
Say, you have a custom control MyControl in the namespace MyNamespace, create a bmp file MyControl.bmp following the above rules. Add this file to your project at the top-level and make it an embedded resource. The project's default namespace should be MyNamespace.
If the control's namespace and the project's default namespace don't match then move the bitmap to appropriate subfolders so that they match. If this is not possible, typically when the namespaces are not related at all then you cannot use this technique, use instead one of the techniques below using the ToolboxBitmap attribute.
Create the assembly and the next time you add it to the toolbox the custom image in MyControl.bmp should be available in the toolbox.
...

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)