Icon to Image

  • Thread starter Thread starter Marcolino
  • Start date Start date
M

Marcolino

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
 
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!
 
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!
 
Marcolino said:
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
 
  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

Thanks to all, it works.
Bye

Marco
 
Back
Top