Welcome, Guest Ohm namah shivoy
www.faqpanel.com
Home | ASP.Net | C-Sharp | Winforms | MS SQL | AJAX | XML | .Net Training*** | Search
Invite friends 
Extras 
VS Tips & Tricks
Top 10 .Net Tools
Special folders in ASP.Net
VS Find Combobox
 Latest Postings - Winform Questions
How do I set Custom Date Format in DateTimePicker (WinForms)?
Use this code -
this.dateTimePicker1.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
this.dateTimePicker1.CustomFormat = "dd/MM/yyyy";
this.dateTimePicker1.ShowUpDown = false;
How can I use a TextBox to enter a password?
Set the TextBox.PasswordChar property to the character that you want to use for password -
textBox1.PasswordChar = '\u25CF';
How can I run an EXE from within my application?
Use the Process class found in the System.Diagnostics namespace.

Process proc = new Process();
proc.StartInfo.FileName = @"Notepad.exe";
proc.StartInfo.Arguments = "";
proc.Start();

How do I dynamically load a control from a DLL?
Use System.Reflection. Assembly to dynamically load a control. If the DLL is named "DLLControls.DLL" and the class you want is "DLLControls.ColorControl", then use the code like -

// load the assembly
System.Reflection.Assembly assembly = Assembly.LoadFrom("DLLControls.DLL");

// get the type
Type t = assembly.GetType("MyControls.MyControl");

// create an instance and add it.
Control c = (Control)Activator.CreateInstance(t);
parent.Controls.Add(c);

What is Global Assembly Cache ?
GAC is an area of memory reserved for storing the assemblies of all .Net applications running on a given computer. The GAC is required by side-by-side execution as well as for sharing assemblies among multiple .Net applications. An assembly must have a strong name and be public—shared assembly—to be installed in the GAC. The Global Assembly Cache Tool adds and removes assemblies from the GAC.
How many Formats are supported by DateTimePicker?
Formats supported by DateTimePicker are -

Long
Short
Time
Custom

How to set DateTimePicker MinDate and MaxDate (Winforms)?
dateTimePicker1.MinDate = DateTime.Today;
dateTimePicker1.MaxDate = DateTime.Today.AddYears( 1 );
What is Local assembly cache ?
Assembly cache that stores compiled classes and methods specific to an application. Each application directory contains a \bin subdirectory containing local assembly cache files. Also known as the application assembly cache.
What is Global Assembly Cache Tool ?
.Net programming tool (GACUtil.exe) for installing, list the contents, and uninstalling to the Global Assembly Cache. It can be called from batch files and scripts.
What does it mean by docking of controls?
Docking is the property of the control to attach itself to a particular edge of the window (or other containing control). You can either dock a control to an edge or to fill the available space in the parent control or window.

Common examples of docking includes menu bar and toolbars which dock themselves at the top of the window so that they may remain at top regardless of the size and of the window.

What base class do all Winforms inherit from?
System.Windows.Forms.Form
How do I prevent the beep when the user presses the Enter key in a TextBox?
You can prevent the beep when the enter key is pressed in a TextBox by deriving the TextBox and overriding OnKeyPress -

public class CustomTextBox : TextBox {
protected override void OnKeyPress( KeyPressEventArgs e )
{
if ( e.KeyChar == (char) 13 )
e.Handled = true;
else
base.OnKeyPress( e );
} }

How do I load a picture into the PictureBox control?
To load a Picture into the PictureBox control drag a PictureBox control and a Command Button from the Toolbox. When you click the Command Button, the picture you specified will be loaded into the Picturebox. The following code is a demonstration -

PictureBox1.Image=Image.FromFile("C:\images\image.gif") //Assuming you have a folder named images in C: drive and a gif image in that

How do I make a TextBox use all upper-case (or lower-case) characters?
Use the CharacterCasing property of the TextBox.

textBox1.CharacterCasing = CharacterCasing.Upper;
textBox2.CharacterCasing = CharacterCasing.Lower;

How do I add custom drawing to a Button?
Subclass Button and add a custom Paint event handler that does you custom drawing.

public class CustomButton : Button
{
public CustomButton()
{
Paint += new PaintEventHandler( ButtonPaint );
}

private void ButtonPaint( object sender, PaintEventArgs e )
{
Pen pen = new Pen( Color.Red );
pen.Width = 8;
e.Graphics.DrawLine( pen, 7, 4, 7, Height - 4 );
pen.Width = 1;
e.Graphics.DrawEllipse( pen, Width - 16 , 6, 8, 8 );
}
}