Skip to content

Archive

Archive for October 15th, 2009

Import System.Drawing.Text namespace

using System.Drawing.Text;

Add a DropDownList and change its name to ListAllFont and write this below code on Form’s load event handler.

private void Form1_Load (object sender, System.EventArgs e)
{
InstalledFontCollection fonts = new InstalledFontCollection();
foreach (FontFamily font in fonts.Families)
    //ListAllFont is ListBox
    ListAllFont.Items.Add(font.Name);
}

String Manipulation in C#

Oct 15
Uncategorized

Trim Function
The trim function has three variations Trim, TrimStart and TrimEnd. The first example show how to use the Trim(). It strips all white spaces from both the start and end of the string.

//STRIPS WHITE SPACES FROM BOTH START + FINSIHE
string Name = " String Manipulation " ;
string NewName = Name.Trim();
//ADD BRACKET SO YOU CAN SEE TRIM HAS WORKED
MessageBox.Show("["+ NewName + "]");

continue reading…

Import System.Diagnostics namespace

using System.Diagnostics;
Process.Start("NET", @"USE U: \\127.0.0.1\Sinpin /PERSISTENT:YES");

Notice for the current user whether the tone is a member of the Administrator user group or not to use this code

WindowsIdentity identity = WindowsIdentity.GetCurrent();
WindowsPrincipal principal = new WindowsPrincipal(identity);
string role = "BUILTIN\\Administrators";
bool IsAdmin = principal.IsInRole(role));

Slider by webdesign