468,107 Members | 1,547 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,107 developers. It's quick & easy.

Icon to Image

Hi,
I have simple needs but I don't know how to implement it.
I have application that create Dynamic Button. I need to set the image
on this button, getting the icon from a form.

So pratically I need to convert dinamically a Form.Icon to
Button.Image runtime, but i don't know how.
Any help would be appreciated.

Many Thanks

Marco
Feb 28 '08 #1
4 4537
On Feb 28, 5:15 am, Marcolino <marco.pozzu...@gmail.comwrote:
Hi,
I have simple needs but I don't know how to implement it.
I have application that create Dynamic Button. I need to set the image
on this button, getting the icon from a form.

So pratically I need to convert dinamically a Form.Icon to
Button.Image runtime, but i don't know how.
Any help would be appreciated.

Many Thanks

Marco
Marco,
IIUC correctly you want to synronize form's icon to a button, you can
do this with the following:

' First save form's icon to somewhere (eg: C: drive)
Me.Icon.ToBitmap.Save("c:\icon.ico",
System.Drawing.Imaging.ImageFormat.Icon)

'Then call this icon image as button's image
Button1.Image = Button1.Image.FromFile("c:\icon.ico")

'
-------------------------------------------------------------------------------

If you button is present and you want to create a new one on runtime:

'Set button properties as you wish (optional)
Me.Icon.ToBitmap.Save("c:\icon.ico",
System.Drawing.Imaging.ImageFormat.Icon)
Dim button As New Button
Me.Controls.Add(button)
button.Name = "button1"
button.Image = button.Image.FromFile("c:\icon.ico")

Hope this helps!
Feb 28 '08 #2
On Feb 28, 10:55 am, kimiraikkonen <kimiraikkone...@gmail.comwrote:
On Feb 28, 5:15 am, Marcolino <marco.pozzu...@gmail.comwrote:
Hi,
I have simple needs but I don't know how to implement it.
I have application that create Dynamic Button. I need to set the image
on this button, getting the icon from a form.
So pratically I need to convert dinamically a Form.Icon to
Button.Image runtime, but i don't know how.
Any help would be appreciated.
Many Thanks
Marco

Marco,
IIUC correctly you want to synronize form's icon to a button, you can
do this with the following:

' First save form's icon to somewhere (eg: C: drive)
Me.Icon.ToBitmap.Save("c:\icon.ico",
System.Drawing.Imaging.ImageFormat.Icon)

'Then call this icon image as button's image
Button1.Image = Button1.Image.FromFile("c:\icon.ico")

'
-------------------------------------------------------------------------------

If you button is present and you want to create a new one on runtime:

'Set button properties as you wish (optional)
Me.Icon.ToBitmap.Save("c:\icon.ico",
System.Drawing.Imaging.ImageFormat.Icon)
Dim button As New Button
Me.Controls.Add(button)
button.Name = "button1"
button.Image = button.Image.FromFile("c:\icon.ico")

Hope this helps
Sorry, some grammer mistakes :-)
(I meant if your button is "not" present);

If i understood your issue correctly, you want to syncronize form's
icon to a button, you can
do this with the following:

' First save form's icon to somewhere (eg: C: drive)
Me.Icon.ToBitmap.Save("c:\icon.ico",
System.Drawing.Imaging.ImageFormat.Icon)

'Then call this icon image as button's image
Button1.Image = Button1.Image.FromFile("c:\icon.ico")

'
-------------------------------------------------------------------------------

If your button is NOT present and you want to create a new one on
runtime:

'Set button properties as you wish (optional)
Me.Icon.ToBitmap.Save("c:\icon.ico",
System.Drawing.Imaging.ImageFormat.Icon)
Dim button As New Button
Me.Controls.Add(button)
button.Name = "button1"
button.Image = button.Image.FromFile("c:\icon.ico")

Hope this helps!
Feb 28 '08 #3
Marcolino schrieb:
I have simple needs but I don't know how to implement it.
I have application that create Dynamic Button. I need to set the image
on this button, getting the icon from a form.

So pratically I need to convert dinamically a Form.Icon to
Button.Image runtime, but i don't know how.
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs _
) Handles Button1.Click
Using lIcon As New Icon(Me.Icon, 16, 16)
Button1.Image = lIcon.ToBitmap
End Using
End Sub

Thorsten Dörfler
--
Microsoft MVP Visual Basic

vb-hellfire visual basic faq | vb-hellfire - einfach anders
http://vb-faq.de/ | http://www.vb-hellfire.de/
Feb 28 '08 #4
On 28 Feb, 10:47, Thorsten Doerfler <t.doerfler_nos...@bdsw.dewrote:
Marcolino schrieb:
I have simple needs but I don't know how to implement it.
I have application that create Dynamic Button. I need to set the image
on this button, getting the icon from a form.
So pratically I need to convert dinamically a Form.Icon to
Button.Image runtime, but i don't know how.

* Private Sub Button1_Click(ByVal sender As System.Object, _
* * * * * * * * * * * * ByVal e As System.EventArgs _
* * * * * * * * * * * * * * * * ) Handles Button1.Click
* * Using lIcon As New Icon(Me.Icon, 16, 16)
* * * Button1.Image = lIcon.ToBitmap
* * End Using
* End Sub

Thorsten Dörfler
--
Microsoft MVP Visual Basic

vb-hellfire visual basic faq *| vb-hellfire - einfach andershttp://vb-faq.de/* * * * * * |http://www.vb-hellfire.de/
Thanks to all, it works.
Bye

Marco
Feb 29 '08 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

9 posts views Thread by arenaTR | last post: by
3 posts views Thread by Hai Ly Hoang [MT00KSTN] | last post: by
reply views Thread by - HAL9000 | last post: by
6 posts views Thread by Udi | last post: by
7 posts views Thread by ozzy66 | last post: by
1 post views Thread by flaerpen | last post: by
1 post views Thread by =?Utf-8?B?QWRhbQ==?= | last post: by
1 post views Thread by Solo | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.