By using System.Drawing.SystemIcons class
for example: System.Drawing.SystemIcons.Warning produces an Icon with a warning sign in it.
Search Your Question
Saturday, April 26, 2008
How can I load the icons provided by .NET dynamically?
In windows forms what class does Icon derive from?
Icon derives from System.Drawing namespace. It's not a Bitmap by default, and is treated separately by .NET.
However, you can use ToBitmap method to get a valid Bitmap object from a valid Icon object
How's anchoring different from docking in windows forms?
Anchoring treats the component as having the absolute size and adjusts its location relative to the parent form. Docking treats the component location as absolute and disregards the component size.
So if a status bar must always be at the bottom no matter what, use docking. If a button should be on the top right, but change its position with the form being resized, use anchoring.
Why is it not a good idea to insert code into InitializeComponent method when working with Visual Studio?
If we insert any code into InitializeComponent method the designer will through it away, because most of the code inside InitializeComponent is auto-generated.
What is ErrorProvider control? When would you use it?
ErrorProvider control is used in Windows Forms application. It is like Validation Control for ASP.NET pages.
ErrorProvider control is used to provide validations in Windows forms and display user friendly messages to the user if the validation fails.
Tuesday, April 22, 2008
How can you save the desired properties of Windows Forms application?
config files in .NET are supported through the API to allow storing and retrieving information. They are nothing more than simple XML files, sort of like what .ini files were before for Win32 apps.
How do you retrieve the customized properties of a .NET application from XML .config file?
Initialize an instance of AppSettingsReader class. Call the GetValue method of AppSettingsReader class, passing in the name of the property and the type expected. Assign the result to the appropriate variable.
My progress bar freezes up and dialog window shows blank, when an intensive background process takes over
Yes, you should’ve multi-threaded your GUI, with taskbar and main form being one thread, and the background process being the other.
or Application.DoEvents can be used also
What’s the difference between WindowsDefaultLocation and WindowsDefaultBounds?
WindowsDefaultLocation tells the form to start up at a location selected by OS, but with internally specified size. WindowsDefaultBounds delegates both size and starting position choices to the OS.
How would you create a non-rectangular window, let’s say an ellipse?
Create a rectangular form, set the TransparencyKey property to the same value as BackColor, which will effectively make the background of the form transparent. Then set the FormBorderStyle to FormBorderStyle.None, which will remove the contour and contents of the form.