By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,761 Members | 1,183 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,761 IT Pros & Developers. It's quick & easy.

VB.Net - Setting all form icons to the application icon

P: n/a
Is their a way in a VB.Net application to set all sub form icons to the main
form ? or even set all icons to the Application icon, without having to
reference the icon as a filename ?

With Thanks

Jason
Nov 21 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Jason,

This answer is so not only for the icons.

Create your own basic form with everything basicly on it, and create from
that inherited forms. (That is an item in the add items in the project
explorer)

I hope this helps,

Cor
Nov 21 '05 #2

P: n/a
"QLD_AU" <Ne**@DigitalSniper.Net> schrieb:
Is their a way in a VB.Net application to set all sub form icons to the
main form ? or even set all icons to the Application icon, without having
to reference the icon as a filename ?


There are different ways to do that:

* You can assign the icon to all forms at designtime.

* You can create a base form that includes the icon and let
all other forms inherit from this base form.

* You can make a reference to the icon or main form available
and assign the icon at runtime, for example, in the forms' constructors:

Providing a reference to an application's main form
<URL:http://dotnet.mvps.org/dotnet/faqs/?id=accessmainform&lang=en>

<URL:http://groups.google.de/groups?selm=OyzrpoUCFHA.392%40TK2MSFTNGP14.phx.gbl >

It's not recommended to assign icons to all forms of an application.
Especially dialogs (forms which are shown modally) typically don't have an
icon at all. Take a look at Microsoft's applications to see when using an
icon in the form's title bar makes sense.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #3

P: n/a
Bob
Just in case this might help you managing icons...

Add some icons to your project, make them embedded resources, then put their
file names in the enum below. Then you can access them easily like so:

Dim i As Icon = Resources.GetIcon(Icons.IconName1)

Watch for line breaks...

------BEGIN CODE-------

Imports System.Reflection

Public Class Resources

Private Sub New()
End Sub

Public Enum Icons
IconName1
IconName2
IconName3
End Enum

Private Shared RootNameSpace As String = GetType(Resources).Namespace

Public Shared Function GetIcon(ByVal Icon As Icons) As Icon
Dim ret As Icon
Dim asm As [Assembly] = [Assembly].GetExecutingAssembly
Dim Name As String = _
RootNameSpace & "." & System.Enum.GetName(Icon.GetType, Icon) &
".ico"
Dim s As System.IO.Stream = asm.GetManifestResourceStream(Name)
If Not s Is Nothing Then
ret = New Icon(s)
s.Close()
End If
Return ret
End Function

End Class

------END CODE-------

"QLD_AU" <Ne**@DigitalSniper.Net> wrote in message
news:42********@duster.adelaide.on.net...
Is their a way in a VB.Net application to set all sub form icons to the main form ? or even set all icons to the Application icon, without having to
reference the icon as a filename ?

With Thanks

Jason

Nov 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.