Sie sind auf Seite 1von 68

Useful links: http://msdn.microsoft.com/express/vcsharp http://www.developer.com/net/cplus/article.php/627891 http://www.codeproject.com/cs/system/cdrom.asp? df=100&forumid=208854&exp=0&select=1427141 http://forums.microsoft.com/msdn/showforum.aspx?forumid=31&siteid=1 http://www.samspublishing.com/library/content.asp? b=STY_Csharp_24hours&seqNum=169&rl=1 http://msdn.microsoft.com/vstudio/express/visualcsharp/learning/default.aspx http://www.devasp.net/net/articles/display/679.html CODES FOR C#: MessageBox.

Show("Write some text here..."); SOMETHING! textBox1.Text = "write text"; THE BUTTON! this.Dispose(); this.Close(); //FOR MESSAGE BOX THAT SAYS

//FOR SHOWING THE TEXT IN THE TEXT BOX BY CLICKING

//FOR CANCEL! //FOR CLOSE!

/*My favourite site... * http://www.pcsx2.net */ COMMENTS! FormName frm=new FormName(); frm.Show();

//FOR GOING ON ANY SITE THROUGH THE

//FOR NEW FORM!

string firstTextBox = textBox1.Text; string secondTextBox = textBox2.Text; label1.Text = firstTextBox + " " + secondTextBox; LABEL BY WRITING IT IN THE 2 TEXT BOXES!

//FOR SHOWING THE TEXT ON THE

MessageBox.Show("I'm about to do something...","MessageBox sample", MessageBoxButtons.OKCancel,MessageBoxIcon.Information); //FOR SHOWING THE MESSAGE BOX WITH OK AND CANCEL BUTTON TOGETHER WITH THE TEXT YOU WROTE! (Information box). MessageBox.Show("I'm about to do something...","MessageBox sample", MessageBoxButtons.OKCancel,MessageBoxIcon.Information, MessageBoxDefaultButton.Button1); //FOR DEFAULT BUTTON ON MESSAGE BOX WITH OK AND CANCEL BUTTON TOGETHER WITH THE TEXT YOU WROTE!

(Information box). MessageBox.Show("Something bad has happened!","Message Box sample", MessageBoxButtons.OK,MessageBoxIcon.Error); //FOR SHOWING THE MESSAGE BOX THAT SHOW'S AN ERROR! (Error box). MessageBox.Show("Would you like to format your hard drive now?", "MessageBox sample",MessageBoxButtons.YesNo,MessageBoxIcon.Question, MessageBoxDefaultButton.Button1); //FOR SHOWING THE MESSAGE BOX WITH YES AND NO BUTTON TOGETHER WITH THE TEXT YOU WROTE! (Question box). this.Hide(); //FOR HIDING THE FORM!

this.Show(); //FOR SHOWING THE FORM ON THE SCREEN AND REMOVING IT FROM THE TASKBAR BY CLICKING ON THE ICON OF THAT FORM! Application.Exit(); //FOR TURNING OFF THE APPLICATION!

private System.Media.SoundPlayer mediaSoundPlayer = new System.Media.SoundPlayer(); //THIS CODE IS NEEDED FOR START AND STOP PLAYING ANY MUSIC! (It's always going above "public Form1()", but it doesn't need to be Form1.It can also be Form2,Form3...and so on). mediaSoundPlayer.Stream = Properties.Resources.NameOfYourMusic; mediaSoundPlayer.PlayLooping(); //FOR START PLAYING ANY MUSIC WITH REPEATING! mediaSoundPlayer.Stop(); //FOR STOP PLAYING ANY MUSIC!

mediaSoundPlayer.Stream = Properties.Resources.NameOfYourMusic; mediaSoundPlayer.Play(); //FOR START PLAYING ANY MUSIC WITHOUT REPEATING! string tadaPath = @"C:\Windows\Media\tada.wav"; mediaSoundPlayer.SoundLocation = tadaPath; mediaSoundPlayer.PlayLooping(); OR MUSIC FROM THE PATH!

//FOR PLAYING ANY SOUND

string tadaPath = @"C:\windows\media\NameOfYourMusic.wav"; mediaSoundPlayer.settings.autoStart = true; mediaSoundPlayer.URL = tadaPath; //WHEN THE APPLICATION TURNS ON,MUSIC OR VIDEO WHICH YOU HAVE CHOSEN WILL START PLAYING IT SELF AUTOMATICALLY! string tadaPath = @"C:\windows\media\NameOfYourMusic.wav"; mediaSoundPlayer.settings.autoStart = false; mediaSoundPlayer.URL = tadaPath; //WHEN THE APPLICATION TURNS ON,MUSIC OR VIDEO WHICH YOU HAVE CHOSEN WON'T START PLAYING IT SELF AUTOMATICALLY!(You will need to turn it on manually on the place where you put the windows media player). /* * Name: * Autor: */

HowdyPartner.cs Joe Mayo

// Beginning class of the program public class HowdyPartner { // Main is beginning executing the program public static void Main() { //Print on the console System.Console.WriteLine("Howdy, Partner!"); } } //FOR SHOWING THE TEXT YOU WROTE IN CONSOLE APPLICATION JUST ON THE MOMENT! INSTEAD THIS---> System.Console.WriteLine("Howdy, Partner!"); <--- YOU CAN ALSO WRITE---> ///"Howdy, Partner!" MessageBox.Show("I'm about to do something...", "MessageBox sample", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning); //FOR SHOWING THE MESSAGE BOX WITH OK AND CANCEL BUTTON TOGETHER WITH THE TEXT YOU WROTE! (Warning box). MessageBox.Show("I'm about to do something...", "MessageBox sample"); SHOWING THE MESSAGE BOX THAT SHOW'S THE //FOR

TEXT YOU WROTE ON TWO PLACES! using System; class STARS { static void Main() { string name; Console.Write("Running STARS Playstation 2 emulator version 00.00.01"); name = Console.ReadLine(); Console.WriteLine("STARS, {0}! } } THE CONSOLE!(The ", name); //FOR SHOWING THE TEXT YOU WROTE IN console won't turn off until you don't do it). [Not understandable still].

using System; using System.Collections.Generic; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { string STARS; Console.WriteLine("Yo man!!!"); STARS = Console.ReadLine(); } } } //FOR SHOWING THE TEXT YOU WROTE IN THE CONSOLE!(The console won't turn off until you don't do it). [This code shows the same thing like the previous code but on a little more simple and better way]. NOTE: If you don't want the console turns off immediately after you start debuging,you must of course write this: Console.WriteLine("write the text you want"); And above that you must also write this: string STARS;

Also bellow this:... Console.WriteLine("write the text you want"); ...you must write: STARS = Console.ReadLine(); Also don't forget the all this writing must go between this 2 brackets:---> {:--->} AFTER YOU HAVE DONE THIS,YOU SHOULD GET THIS: { string STARS; Console.WriteLine("write the text you want"); STARS = Console.ReadLine();

} NOTE: The word doesn't need to be "STARS".It can also be any other word you want.For example MARK,book,Computer...blabla But then that word must be written on that two places.I will take for example word "Computer" : { string Computer; Console.WriteLine("write the text you want"); Computer = Console.ReadLine();

string test; test = "Hello all!!!"; MessageBox.Show(test); MessageBox.Show("What's up?!!"); //CODE FOR SHOWING THE TWO TEXT BOXES WITH DIFFERENT TEXTS YOU WROTE! (Note that the word "test" is written on 3 places.Without that word, the program won't work.The word doesn't need to be "test".It can be also any other word you want,but be sure the that word is written on all this 3 places where the word "test" is written). float firstTextBox = 0; float secondTextBox = 0; float result = 0; firstTextBox = float.Parse(textBox1.Text); secondTextBox = float.Parse(textBox2.Text); result = firstTextBox + secondTextBox; label1.Text = result.ToString(); //WITH THIS CODE YOU CAN COUNT ANY FULL OR DECIMAL NUMBERS! (If instead word "float" you put the word "int" ,you won't be able to count with decimal numbers.Only with full numbers). button1.BackgroundImage = Properties.Resources.Umbrella_3; //WITH THIS CODE,WHEN YOU HOVER THE BUTTON WITH YOUR MOUSE,THE PICTURE YOU HAVE CHOOSEN WILL BE SHOWED ON THAT BUTTON! (You must do this in the events of that button).

button1.BackgroundImage = Properties.Resources.hl1; //AFTER YOU REMOVE THE MOUSE FROM THE BUTTON, PREVIOUS PICTURE WHICH YOU HAVE CHOOSEN WILL BE SHOWED ON THAT BUTTON! (You must do this in the events of that button). if (button1.Dock == DockStyle.Fill) { button1.Dock = DockStyle.None; } else { button1.Dock = DockStyle.Fill; } //FOR STRETCHING THE BUTTON BY CLICKING ON IT! (The button will become bigger after you click on it.For this option,table layout panel is needed). Button thisButton = (Button)sender; MessageBox.Show(thisButton.Name, "Hi lol"); //WITH THIS CODE THE NAME OF THE MESSAGE BOX WILL BE WHAT YOU WROTE, FOR EXAMPLE HERE I WROTE "Hi lol",AND THE TEXT IN THAT MESSAGE BOX WILL BE THE SAME LIKE THE NAME OF THE BUTTON WHICH YOU WERE USING FOR THIS OPTION! (Also this same code can be used in events so you have the same function for more buttons. For example when you click the "button1",there will of course be the name of the message box you wrote and if text in the name of that button is for example "YO!",when you click on that button the text in the message box will be "YO!".For "button2",select it and go in his events and in "Click" choose "button1".After you click on that "button2" the name of the message box will be what you wrote and the text in that message box will be the same like the text in the name of that "button2"). if (fontDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK) richTextBox1.SelectionFont = fontDialog1.Font; //WITH THIS CODE,AFTER YOU CLICK ON THE BUTTON,THE FONT WINDOW WILL APPEAR! (For this option,rich text box and font dialog is needed). if (colorDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK) richTextBox1.SelectionColor = colorDialog1.Color; //WITH THIS CODE,AFTER YOU CLICK ON THE BUTTON THE COLOR WINDOW WILL APPEAR! (For this option, rich text box and color dialog is needed). openFileDialog1.Title = "Open File"; openFileDialog1.Filter = "TEXT FILES (*.rtf)|*.rtf|ALL FILES (*.*)|*.*"; openFileDialog1.FileName = ""; openFileDialog1.FilterIndex = 0; openFileDialog1.InitialDirectory = "My Documents";

openFileDialog1.CheckFileExists = true; openFileDialog1.CheckPathExists = true; if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK) { richTextBox1.LoadFile(openFileDialog1.FileName); } //WITH THIS CODE YOU CAN OPEN ANY TEXT FILE AFTER YOU CLICK ON THE BUTTON! (For this option, open file dialog and rich text box is needed). richTextBox1.Rtf = ""; //WITH THIS CODE YOU CAN DELETE THE WHOLE TEXT YOU WROTE! (After you click on the button, whole text you wrote will be immediately deleted.For this option,rich text box is needed). pageSetupDialog1.Document = printDocument1; pageSetupDialog1.PageSettings = printDocument1.DefaultPageSettings; pageSetupDialog1.AllowMargins = true; pageSetupDialog1.AllowOrientation = true; pageSetupDialog1.AllowPaper = true; pageSetupDialog1.AllowPrinter = true; pageSetupDialog1.ShowNetwork = true; pageSetupDialog1.ShowHelp = true; pageSetupDialog1.EnableMetric = true; if (pageSetupDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK) printDocument1.DefaultPageSettings = pageSetupDialog1.PageSettings; //FOR OPENING THE PAGE SETUP! (For this option,page setup dialog and print document is needed). printDialog1.Document = printDocument1; if (printDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK) { printDocument1.Print(); } //FOR PRINT! (For this option,print dialog and print document is needed). saveFileDialog1.DefaultExt = ".rtf"; saveFileDialog1.OverwritePrompt = true; saveFileDialog1.Title = "Save File"; if (saveFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK) { richTextBox1.SaveFile(saveFileDialog1.FileName, RichTextBoxStreamType.RichText); } //FOR SAVING THE TEXT FILES ON ANY PLACE ON YOUR COMPUTER! (For this option,save file dialog and rich text box is needed). OpenFileDialog fileDlg = new OpenFileDialog(); fileDlg.Filter = "IMAGE FILES (*.bmp; *.gif; *.jpg; *.png)|*.bmp;*.gif;*.jpg;*.png|" +

"ALL FILES (*.*)|*.*"; ; if (fileDlg.ShowDialog() == DialogResult.OK) { try { pictureBox1.Image = Image.FromFile(fileDlg.FileName); } catch (Exception) { MessageBox.Show(this, "Unable to load the image!", "Loading image failed"); } } //FOR LOADING THE IMAGE! (For this option, picture box is needed). openFileDialog1.Title = "Open File"; openFileDialog1.Filter = "TEXT FILES (*.rtf)|*.rtf|ALL FILES (*.*)|*.*"; openFileDialog1.FileName = ""; openFileDialog1.FilterIndex = 0; openFileDialog1.InitialDirectory = "My Documents"; openFileDialog1.CheckFileExists = true; openFileDialog1.CheckPathExists = true; if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK) try { richTextBox1.LoadFile(openFileDialog1.FileName); } catch (Exception) { MessageBox.Show("Loading the text failed!","FAILED loading the text"); } //WITH THIS CODE THE FUNCTION IS SAME LIKE THAT ONE FROM BEFORE AND THAT IS THE YOU CAN OPEN ANY TEXT FILE,BUT HERE IS ALSO A MESSAGE BOX WHICH WILL SAY IF LOADING THE TEXT HAS FAILED! NOTE:The message box which will say us the loading text has failed is made on this way.Above this: { richTextBox1.LoadFile(openFileDialog1.FileName);

} We wrote a word "try".And bellow this: { richTextBox1.LoadFile(openFileDialog1.FileName); } We wrote this: catch (Exception) { MessageBox.Show("Loading the text failed!","FAILED loading the text"); } Button newButton = new Button();

newButton.Name = textBox1.Text; newButton.Text = textBox2.Text; flowLayoutPanel1.Controls.Add(newButton); //FOR ADDING THE NEW BUTTONS ON THE FORM BY CLICKING ON THE BUTTON!(For this option,2 text boxes and flow layout panel is needed). switch (comboBox1.Text) { case "BottomUp": flowLayoutPanel1.FlowDirection break; case "LeftToRight": flowLayoutPanel1.FlowDirection break; case "TopDown": flowLayoutPanel1.FlowDirection break; case "RightToLeft": flowLayoutPanel1.FlowDirection break; }

= FlowDirection.BottomUp; = FlowDirection.LeftToRight; = FlowDirection.TopDown; = FlowDirection.RightToLeft;

//THIS CODE IS FOR 4 DIFFERENT SEQUENCES FOR THE BUTTONS WHICH YOU ADDED THANKS TO THE PREVIOUS CODE! (With this code you can put the buttons,[which you added],on 4 different sequences.And that are:bottom up,left to right,top down and right to left.For this option, box and flow layout panel is needed). if (checkBox1.Checked == true) flowLayoutPanel1.WrapContents = true; else flowLayoutPanel1.WrapContents = false; //WITH THIS CODE,ALL BUTTONS YOU ADDED ON THE FORM,THEY WILL ALL BE SHOWED ON THE FORM,IF THERE IS ENOUGH PLACE FOR THEM IN FLOW LAYOUT PANEL!(That will happen if you put the mark in that check box.For this option,check box and flow layout panel is needed). if (checkBox2.Checked == true) flowLayoutPanel1.AutoScroll = true; else flowLayoutPanel1.AutoScroll = false; //WITH THIS CODE,ALL BUTTONS YOU ADDED ON THE FORM,THEY WILL ALL BE SHOWED ON THE FORM,BUT YOU WILL SEE THEM ALL THANKS TO THE ARROWS WHICH ARE AUTOMATICALLY CREATED IF YOU CREATED MORE BUTTONS THEN THERE IS A SPACE ON FLOW LAYOUT PANEL! (For this option,check box and flow layout panel is needed). private Icon oldIcon; //IF YOU WANT TO HAVE AN ICON IN THE TASKBAR,YOU MUST ALWAYS WRITE THIS ABOVE "public Form1()" ! (That "oldIcon" must always be the name of our first icon which we chose in notify icon).[Notify icon is in the toolbox].

oldIcon = notifyIcon1.Icon; //THIS CODE MUST BE WRITTEN ON THE PLACE AFTER YOU DOUBLE CLICK ON THE FORM! (In this code you again have "oldIcon".And like I said before,that "oldIcon" must always be the name of our first icon which we chose in the notify icon). notifyIcon1.Icon = Properties.Resources.NameOfYourIcon; //THIS CODE IS NEEDED IF WE WANT TO APPLY THE NEW BY CLICKING ON THE BUTTON! notifyIcon1.Icon = oldIcon; //THIS IS NEEDED IF WE WANT TO LOAD OUR PREVIOUS,CORRECTLY OUR OLD ICON BY CLICKING ON THE BUTTON!(In this code you again can see "oldIcon". And like I already said,that "oldIcon" is the name of our first,I mean old icon which we want to load by clicking on the button). NOTE: For more options in our icon,we must add the context menu strip on the form and then load that context menu strip in the notify icon.And the place in notify icon where we want to load the context menu strip is called "ContextMenuStrip" !!!And then in that context menu strip we can put many buttons and write the code for them.I am usually using 2 buttons and that are SHOW method and HIDE method.Also if we want the form be showed by clicking on the icon 2 times with our left mouse click,we must do that in the events of that notify icon! process1.EnableRaisingEvents = true; process1.Start(); //FOR OPENING THE NOTEPAD BY CLICKNG ON THE BUTTON!(For this option,process is needed.Also this code won't work if you do not do the following.Choose process then go in his "Properties",then go in the "StartInfo" then in the "FileName" write "notepad.exe" and in the "WorkingDirectory" write "%system%\system32".But if you want to use something else instead the notepad, in the "FileName" just simply write "wordpad.exe"). process1.Kill(); //FOR CLOSING THE NOTEPAD BY CLICKING ON THE BUTTON! (For this option process is needed. This code is usually used together with the previous code so you can easily close the notepad by clicking on the button.But if you want the there is a message box which will say something after you clicked this button for closing the notepad, just simply write the code for the message box bellow this code.That message box will be showed only if you click on that button for closing the notepad.Because if you close the notepad by clicking on his X/close button,the message box won't be showed). NOTE: If you want the message box,(with the text you want),be showed if you click the closing button or X/close button on the notepad, bellow this: { } Write this: process1.Kill();

private void notepadProcess_Exited(object sender, EventArgs e) { MessageBox.Show("NOTEPAD CLOSED!", "Notepad closed", MessageBoxButtons.OK); } And after you have done all this,again choose the process and go in his "Properties",then go in the events then choose the "Exited".There write or even better choose "notepadProcess_Exited". string programFilesPath = System.Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles); string iePath = System.IO.Path.Combine(programFilesPath, @"Internet Explorer\IExplore.exe"); process2.EnableRaisingEvents = true; process2.StartInfo.FileName = iePath; process2.Start(); //FOR OPENING THE INTERNET EXPLORER BY CLICKING ON THE BUTTON! (For this option,process is needed. This time,do not change anything in the "Properties" of this process if you are using this code). NOTE:If this time you again you want the there is a message box which will say something after you clicked the close button to close the internet explorer or if you clicked the X/close on the internet explorer,bellow this: { process2.Kill(); } Write this: private void internetExplorerProcess_Exited(object sender, EventArgs e) { MessageBox.Show("INTERNET EXPLORER CLOSED!", "Internet Explorer closed", MessageBoxButtons.OK); } And after you have done all this,do the same thing like before on the previous example.Choose the process and go in his "Properties",then go in the events then choose the "Exited".There write or even better choose "internetExplorerProcess_Exited". string MyName; MyName = "Freeman"; MessageBox.Show(MyName); //STRING THAT SHOWS THE WORD "Freeman"! string car = "Hello"; MessageBox.Show(car); //STRING THAT SHOWS THE WORD "Hello"! string car; string bike; car = "Hello man!!"; bike = "What's up?!"; MessageBox.Show(car + bike);

//TWO STRINGS THAT SHOWS "Hello man!!What's

up?!"! openFileDialog1.Title = "Open File"; openFileDialog1.Filter = "MP3 FILES (*.mp3)|*.mp3|ALL FILES (*.*)|*.*"; openFileDialog1.FileName = ""; openFileDialog1.FilterIndex = 0; openFileDialog1.InitialDirectory = "My Documents"; openFileDialog1.CheckFileExists = true; openFileDialog1.CheckPathExists = true; if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK) { tadaPath = openFileDialog1.FileName; count++; MessageBox.Show("Now click on the windows media player!","Click on the windows media player"); } //WITH THIS CODE YOU CAN OPEN ANY MP3 FILE AND THEN LISTEN IT IN THE WINDOWS MEDIA PLAYER!(For this option windows media player and open file dialog is needed). NOTE: This code won't work if above "public Form1()" you don't write this: string tadaPath = ""; int count = 0; Also in the windows media player you must write this: if (count >= 1) { MessageBox.Show("File is now ready to be played!","File is ready"); } mediaSoundPlayer.settings.autoStart = false; mediaSoundPlayer.URL = @tadaPath;

OpenFileDialog fileDlg = new OpenFileDialog(); fileDlg.Filter = "ALL IMAGE FILES (*.*)|*.*"; if (fileDlg.ShowDialog() == DialogResult.OK) { { pictureBox1.Image = Image.FromFile(fileDlg.FileName); } } //THIS CODE IS FOR OPENING ALL TYPE OF IMAGES!(For this option,picture box is needed). Bitmap b = (Bitmap)pictureBox1.Image;

SaveFileDialog save = new SaveFileDialog(); save.Filter = "Image Files(*.jpg; *.jpeg; *.gif; *.bmp)|*.jpg; *.jpeg; *.gif; *.bmp"; if (save.ShowDialog() == DialogResult.OK) { b.Save(save.FileName); } //WITH THIS YOU CAN SAVE THE PICTURE ON ANY PLACE ON YOUR COMPUTER!(For this option,picture box is needed). Bitmap b = (Bitmap)pictureBox1.Image; SaveFileDialog save = new SaveFileDialog(); save.Filter = "BMP (*.bmp)|*.bmp|JPEG (*.jpeg)|*.jpeg|JPG (*.jpg)|*.jpg|GIF (*.gif)|*.gif| PNG (*.png)|*.png|TIFF (*.tiff)|*.tiff|DIB (*.dib)|*.dib|JPE (*.jpe)|*.jpe|JFIF (*.jfif)|*.jfif"; if (save.ShowDialog() == DialogResult.OK) { b.Save(save.FileName); } //WITH THIS CODE YOU CAN ALSO SAVE THE PICTURE ON ANY PLACE ON YOUR COMPUTER,BUT WITH THIS CODE YOU CAN SAVE THE PICTURE IN ANY FORMAT YOU WANT!(For this option,picture box is needed). string laptop; string computer; string word; string car; laptop = "Hello."; computer = "How are you today? "; word = "I am fine..."; car = "and you?"; MessageBox.Show(laptop + computer + word + car + "","Text is bellow"); //FOUR STRINGS THAT SHOWS THE NAME OF THE MESSAGE BOX "Text is bellow" AND THE TEXT IN THAT MESSAGE BOX "Hello.How are you today? I am fine...and you?"!

splitContainer1.IsSplitterFixed = true; this code,after you click the split the word

//FOR FIXING THE SPLITTER!(With on the button,you won't more be able to resize container.But if instead word "true" you write "false" you will be able to resize the split

container.For

this option,split container is needed). //FOR SETTING THE SPLITTER WIDTH! the split container will become wider on the number "100" so the split container will become right enough,but if the number is 10,split become wider on the right just a little.For this container is needed).

splitContainer1.SplitterWidth = 100; (After you click on the button, right.Here is wider on the container will option,split

splitContainer1.SplitterDistance = 30; (After you click on the button,the of your not be very the number 250 left end of needed).

//FOR SETTING THE SPLITTER LEFT! split container will go on the left,where is the end form.Here is number "30" so the split container will far from the left end of your form.But if you put or more,the split container won't be close to the your form.For this option,split container is

Button firstButton = new Button(); firstButton.Name = "firstButton"; firstButton.Text = "First Button"; tableLayoutPanel1.Controls.Add(firstButton, 0, 0); Button secondButton = new Button(); secondButton.Name = "secondButton"; secondButton.Text = "Second Button"; tableLayoutPanel1.Controls.Add(secondButton, 1, 0); Button thirdButton = new Button(); thirdButton.Name = "thirdButton"; thirdButton.Text = "Third Button"; tableLayoutPanel1.Controls.Add(thirdButton, 0, 1); tableLayoutPanel1.CellBorderStyle = TableLayoutPanelCellBorderStyle.Inset; tableLayoutPanel1.GrowStyle = TableLayoutPanelGrowStyle.AddRows; Button fourthButton = new Button(); fourthButton.Name = "fourthButton"; fourthButton.Text = "Fourth Button"; tableLayoutPanel1.Controls.Add(fourthButton, 1, 1);

Button fifthButton = new Button(); fifthButton.Name = "fifthButton"; fifthButton.Text = "Fifth Button"; tableLayoutPanel1.Controls.Add(fifthButton, 0, 2); Button sixthButton = new Button(); sixthButton.Name = "sixthButton"; sixthButton.Text = "Sixth Button"; tableLayoutPanel1.Controls.Add(sixthButton, 1, 2); Button seventhButton = new Button(); seventhButton.Name = "seventhButton"; seventhButton.Text = "Seventh Button"; tableLayoutPanel1.Controls.Add(seventhButton, 0, 3); tableLayoutPanel1.AutoScroll = true; //IN THIS CODE,YOU CAN ADD MANY BUTTONS AS YOU WANT ON THE TABLE LAYOUT PANEL!(This code must be written in the place where you get if you click two times on the form.For this option,table layout panel is needed). label2.Text = System.DateTime.Now.ToLongTimeString(); //WITH THIS CODE,YOU CAN USE A TIMER LIKE A CLOCK!(This code must be written on the place where you get after you click on the form 2 times.Also this code must be written on the place where you get after you click on the timer two times.This is usually used for the basic timer which you take from your toolbox.For this option, timer is needed). timer1.Enabled = true; BUTTON!(For the basic timer). timer1.Enabled = false; BUTTON!(For the basic timer). //FOR STARTING THE TIMER BY CLICKING THE

//FOR STOPING THE TIMER BY CLICKING THE

label2.Text = System.DateTime.Now.ToLongTimeString(); //WITH THIS CODE YOU CAN AGAIN USE THE TIMER LIKE A CLOCK OR SOMETHING ELSE!(This code must be written on the

on the where you times.This is take from "General" section.

place where you get after you click two times form and it also must be written on the place get after you click on the timer two usually used for the special timer which you your toolbox if you added it from the For this option,timer is needed).

timer1.Start(); BUTTON!(For the special timer). timer1.Stop(); (For the special timer).

//FOR STARTING THE TIMER BY CLICKING THE

//FOR STOPING THE TIMER BY CLICKING THE BUTTON!

if (comboBox1.Text == "Emil") { MessageBox.Show("You chose Emil!"); comboBox1.Text = ""; } //THIS IS AN EXAMPLE FOR THE COMBO BOX!(Here I edited the items by putting two words.And that are "Marin" and "Emil".Only if you choose "Emil" then click the button,only for "Emil" will work because we didn't write a code for "Marin".So when you choose "Emil" and click the button,there will be a message box which will contain text "You chose Emil!".For this option,combo box is needed). if (comboBox1.Text == "Marin") MessageBox.Show("Hehehe lol"); //THIS IS ALSO AN EXAMPLE FOR THE COMBO BOX!(After you choose "Marin" and then click the button,the message box will be showed which will contain text "Hehehe lol".Also note the this and the previous code must be written in that button which we are using for this option, not in the combo box.For this option,combo box is needed). if (comboBox1.Text != "Conrad") { if (comboBox1.Text == "Grant")

} else { MessageBox.Show("CONRAD IS PICKED!!!"); } //THIS IS A HARDER EXAMPLE FOR THE COMBO BOX!(In here I edited 2 items.And that are "Conrad" and "Grant".In the first row I used the "if" statement for the false value for the "Conrad". So that value won't be executed because it's false.After that I again used the "if" statement for the true value for the "Grant".Then of course I wrote the action which I want to happen for the "Grant" and in this case it's the message box. After that I used the "else" statement if the user didn't choose any option,so there will be a message box which will tell to the user he didn't choose anything.After all this I again used the "else" statement for the "Conrad".So if the "Conrad" is chosen,there will be a message box which will say that.For this option,combo box is needed). if (comboBox1.Text != "Marin") { if (comboBox1.Text == "Emil") { MessageBox.Show("TEST NUMBER 2!!!"); } if (comboBox1.Text == "Vesna") { MessageBox.Show("TEST NUMBER 3!!!"); } } else { MessageBox.Show("TEST NUMBER 1!!!"); } //ANOTHER EXAMPLE FOR THE COMBO BOX!

MessageBox.Show("YOU PICKED GRANT!!!"); } else { MessageBox.Show("You didn't choose an option!"); }

switch (listBox1.SelectedItem.ToString()) { case "Marin": MessageBox.Show("LOL"); break; } //EXAMPLE FOR THE LIST BOX!(Here in the list box I added 4 words. And that are "Marin","Emil","Vesna" and "Ivan".And after in the list box you choose "Marin" and click the button,there will be a message box which will say "LOL".But if you choose any other words of those 3,nothing won't happen because we didn't write a code for them. For this option,list box is needed). switch (listBox1.SelectedItem.ToString()) { case "Marin": MessageBox.Show("LOL"); break; default: MessageBox.Show("This one is not working"); break; } //ANOTHER EXAMPLE FOR THE LIST BOX!(In this example I didn't add anything new.Just bellow the prevoius code I also wrote the code for "default" and with that,if you choose something in the list box and it's not written here in the code,the message box will appear with the text "This one is not working".For this option,list box is needed). string[] test = new string[3]; test[0] = "Marin"; test[1] = "Emil"; test[2] = "Dad"; MessageBox.Show(test[0]); //THIS IS ONLY ONE STRING WHICH YOU CAN ALSO USE FOR MORE OPTIONS,NOT JUST ONE! (In this example,name of my string is "test".In the first row you can see this "[]" on the right side of the first word.Then there is the name of my string and then you can also see this on the end of the first row "[3]". Then in the next 3 rows you can see I wrote the name of my

string then I and "Dad".In the say "Marin" in the message the text "Marin" will if the number strings for the text. 3,then you can this: "0" then "1" and contain the same or must not be less number 9,then number 0).

wrote the word I wanted.In this case that are "Marin","Emil" last row I added a message box which will say "Marin".It will because in the second row the number is 0.So I also wrote it box together with my string name.So the message box with appear by clicking on the button.Now...the important thing is in the first row is 3 then you must not add more then 3 Also first number is always 0.So if in the first row is number add maximum 3 strings starting from number 0.I mean on the last one is "2".So the number of your strings must not higher number then the number in the first row.Also number then number 0.So for example if in the first row I write the you can add maximum 9 new strings starting from the

string[] test = { "Marin", "Emil", "Vesna", "Bob" }; MessageBox.Show(test[1]); //IN THIS EXAMPLE YOU CAN ALSO USE ONE STRING FOR MORE OPTIONS, BUT IT'S BASICALLY SAME LIKE IN THE PREVIOUS EXAMPLE!(So if you write this code and click the button,the message box with the text "Emil" will appear.It will be "Emil" because in the second row it's number 1 together with out string name.So like I said before,number 0 is the first,number 1 is the second and so on...so if in the second row I write the number 0 instead number 1,the text in the message box will be "Marin"). string[] test = { "Marin", "Emil", "Vesna", "Bob" }; foreach (string person in test) { MessageBox.Show(person); } //HERE YOU CAN ALSO USE JUST ONE STRING FOR MORE OPTIONS!(With this code after you click the button,there are going to be 4 message boxes and each of them

has.Here I wrote 4 after you click on be showed.After automatically be box will show the

will say one word.It depends what sequence your words words and that are "Marin","Emil","Vesna" and "Bob".So the button,the first message box with the text "Marin" will you click on the "OK" button on that message box,there will a second message box with the text "Emil".Third message text "Vesna" and the fourth one will show the text "Bob").

for (int i = 0; i < 7; i++) { MessageBox.Show(i.ToString()); } //THIS CODE IS FOR SHOWING THE MESSAGE BOXES WITH MAXIMUM NUMBERS YOU WROTE IN THE FIRST ROW!(In the first row you can see number 7."i" is less then 7 because it's "i = 0" so that means the "i" is number 0 which is less then number 7.So when you click on the button,there is going to be 6 message boxes. First one will have the text "0",second will have "1",third will have "2", fourth will have "3",fiveth will have "4",sixth will have "5" and the last one will have the text "6"). int i = 0; while (i < int.Parse(textBox1.Text)) { i++; } MessageBox.Show("The final value is: " + i.ToString()); //IF YOU FOR EXAMPLE IN THE TEXT BOX WRITE NUMBER 6 AND THEN PRESS THE BUTTON,THE MESSAGE BOX WILL BE SHOWED AND THE TEXT WILL BE "The final value is: 6"!(If that "i" is number 0 and it's set to "++" then in the text box you must write number 0 or any higher number.After that,by clicking on the button there will be a message box which will say the value.But if you write the "i" is for example number 9,then in the text box you

number because which write will say set -9,and in must write number -4 or needed).

must write number 9 or any higher "i" is set the he is less then the value we are writing in the text box.So if you number 4 and the "i" is 9,message box the value is 9.Also for example if you "int i = -9;" so then "i" is number if he is set the he is less then the value the text box then in the text box you number -9 or higher.For example number 2.For this option,text box is

string[] test = { "Marin", "Emil", "Vesna", "Bob" }; for (int i = 0; i < test.Length; i++) { if (test[i] == "Vesna") { MessageBox.Show("VESNA HAS BEEN FOUND!"); } } //AFTER CLICKING ON THE BUTTON,WE WILL GET "Vesna" IMMEDIATELY EVEN IF IT'S ON THE PLACE 2,NOT 0!(Using the breakpoints here,will help you to understand how this code works). for (int i = 0; i < listBox1.SelectedItems.Count; i++) { switch (listBox1.SelectedItems[i].ToString()) { case "Bob": MessageBox.Show("BOB!!!"); break; case "Niall": MessageBox.Show("NIALL!!!"); break; case "Marin": MessageBox.Show("MARIN!!!"); break; case "Emil": MessageBox.Show("EMIL!!!"); break;

} } ITEMS IN THE LIST BOX ITEMS WILL ALL more options and chose,will he is that in at least one button,otherwise button,nothing "i" is 0.And the four items in won't be less then list box items and we the button example solution is choose every item executed.If "i" is list box and option,list box

//WITH THIS CODE,AFTER YOU CHOOSE THE YOU WANT AND THEN CLICK THE BUTTON,THAT BE EXECUTED!(In the list box choose one or then click the button.After that all options you be executed.Here "i" is number 0 and it's set the less then the value in the list box.You can see the first row.So that means the you must choose item from the list box and then click on the if you don't choose anything and you click the won't happen because we chose 0 items and the "i" which is 0 is equale to 0 items we selected in list box.But if "i" is number 1 and we selected the list box,3 of them will be executed and fourth executed because that number 1 is set the he is the value in the list box.In this case value in the is 4.For example if in the list box we have 5 chose them all and if "i" is number 3,by clicking only 2 items of all 5 items will be executed.That will work if "i" is also set to "++".But the best the "i" is number 0.Then you don't need to in the list box so the only few of them be number 0,then you can choose any item in the that item you chose will be executed.For this is needed).

NOTE: If in the list box you want to choose more then just one item,in the "Properties" of that list box,in the "SelectionMode" you must put "MultiSimple" instead "One".

if (comboBox1.Text == "") { MessageBox.Show("CHOOSE THE OPTION!!!"); } { if (comboBox1.Text == "Test (1)") { MessageBox.Show("TEST 1 IS GOOD!"); } if (comboBox1.Text == "Test (2)") { MessageBox.Show("TEST 2 IS GOOD!"); } if (comboBox1.Text == "NOT FINISHED") { MessageBox.Show("THIS OPTION ISN'T FINISHED!!!"); } } //THIS IS A GOOD EXAMPLE FOR THE COMBO BOX!(In this example,if the user does not choose anything in the combo box,there will be a message box which will tell that to him,if of course the user clicks the button.For this option,combo box is needed). NOTE:That is made on this way.Above this: { if (comboBox1.Text == "Test (1)") { MessageBox.Show("TEST 1 IS GOOD!"); } if (comboBox1.Text == "Test (2)") { MessageBox.Show("TEST 2 IS GOOD!"); } if (comboBox1.Text == "NOT FINISHED") { MessageBox.Show("THIS OPTION ISN'T FINISHED!!!"); } } ...you must write this: if (comboBox1.Text == "") { MessageBox.Show("CHOOSE THE OPTION!!!"); }

int result = AddTwoNumbers(3, 5); MessageBox.Show(result.ToString());

//BY CLICKING ON THE

BUTTON,YOU WILL GET A MESSAGE BOX NOTE:That code won't work if bellow this: { int result = AddTwoNumbers(3, 5); MessageBox.Show(result.ToString()); }

WITH THE NUMBER "8"!

you don't write this: public int AddTwoNumbers(int firstNumber, int secondNumber) { return firstNumber + secondNumber; } public void displayMessage(string message) { MessageBox.Show(message); } int result = AddTwoNumbers(3, 5); displayMessage(result.ToString()); THE SAME BY CLICKING ON THE same code bellow

//IN THIS EXAMPLE YOU WILL GET BUTTON!(Also note the you must write the this code like in the previous example).

displayMessage(AddTwoNumbers(3, 5).ToString()); //THIS IS ALSO AN EXAMPLE IN WHICH YOU WILL GET THE SAME BY CLICKING THE BUTTON!(Again note the that long code must be written bellow this code like in the example before this previous one).

First myFirst; myFirst = new First(); myFirst.Make = "Oldsmobile"; myFirst.Model = "Cutlas Supreme"; myFirst.ElapsedMileage = 200000; MessageBox.Show(myFirst.Make); WILL GET THE MESSAGE BOX WITH THE understand the strings, First myFirst = new First(); myFirst.Make = "Oldsmobile"; myFirst.Model = "Cutlas Supreme";

//BY CLICKING ON THE BUTTON,YOU TEXT "Oldsmobile"!(One example).[If you then you should understand this].

myFirst.ElapsedMileage = 200000; MessageBox.Show(myFirst.Make); //BY CLICKING ON THE BUTTON YOU WILL GET EXACTLY THE SAME LIKE IN THE PREVIOUS EXAMPLE!(Second example).[If you understand the strings, then you should understand this]. NOTE:This two examples won't work if you don't add new class to your project.Here in my project I added a new class and I called it "First.cs".Then your class name in the code view should look like this: using System; using System.Collections.Generic; using System.Text; namespace WindowsApplication1 { class First { <--} <--} And if you want the one of those two examples works,between that two brackets which I marked with arrows,you must write this: //Examples of fields private string _make; private string _model; private int _elapsedMileage; //Examples of properties public string Make { get { return _make; } set { _make = value; } } public string Model { get { return _model; } set { _model = value; } } public int ElapsedMileage { get { return _elapsedMileage; } set { _elapsedMileage = value; } }

First myFirst = new First(); myFirst.Make = "Oldsmobile"; myFirst.Model = "Cutlas Supreme"; myFirst.ElapsedMileage = 200000; string result;

result = myFirst.Drive(30); MessageBox.Show(result); //BY CLICKING ON THE BUTTON,YOU WILL GET A MESSAGE BOX WITH THE TEXT "The Oldsmobile Cutlas Supreme now has 200030 miles."! NOTE:This code of course won't work if you don't do the same thing like in the previous example.So after you added a new class and called it "First.cs",in him between that two brackets of course this must be written: //Examples of fields private string _make; private string _model; private int _elapsedMileage; //Examples of properties public string Make { get { return _make; } set { _make = value; } } public string Model { get { return _model; } set { _model = value; } } public int ElapsedMileage { get { return _elapsedMileage; } set { _elapsedMileage = value; } } ...and bellow that you must also write this: public string Drive(int miles) { _elapsedMileage += miles; string result; result = "The " + _make + " " + _model + " now has " + _elapsedMileage + " miles."; return result; }

First myFirst = new First(); myFirst.Make = "Oldsmobile"; myFirst.Model = "Cutlas Supreme"; myFirst.ElapsedMileage = 200000; myFirst.Drive(40); MessageBox.Show(myFirst.ElapsedMileage.ToString()); //AFTER CLICKING ON THE BUTTON,YOU WILL GET A MESSAGE BOX WITH THE TEXT "200040"!(Also note the in the class everything must be written exactly the same

like in the

previous example).

First myFirst = new First(); myFirst.Make = "Oldsmobile"; myFirst.Model = "Cutlas Supreme"; myFirst.ElapsedMileage = 200000; myFirst.Drive(40); MessageBox.Show(myFirst.ElapsedMileage.ToString()); if (myFirst.Make == "Oldsmobile") { string myModel; myModel = myFirst.Model; MessageBox.Show(myModel); } //AFTER CLICKING ON THE BUTTON,YOU WILL GET TWO MESSAGE BOXES.FIRST WILL SAY "200040" AND THE SECOND ONE WILL SAY "Cutlas Supreme"! (Again be sure the in the class you added must be written that long code like in the previous example).

System.Diagnostics.Process.Start("Shutdown", "-s -t 0"); BUTTON,YOUR COMPUTER WILL SHUT DOWN! System.Diagnostics.Process.Start("ShutDown", "/r -t 0"); BUTTON,YOUR COMPUTER WILL RESTART!

//AFTER YOU CLICK THE

//AFTER YOU CLICK THE

System.Diagnostics.Process.Start("ShutDown", "-l -t 0"); BUTTON,YOUR COMPUTER WILL LOG OFF!

//AFTER YOU CLICK THE

api.mciSendString("set CDAudio door open", null, 127, 0); BUTTON,THE CD-ROM TRAY WILL OPEN! api.mciSendString("set CDAudio door closed", null, 127, 0); THE BUTTON,THE CD-ROM TRAY WILL CLOSE!

//AFTER YOU CLICK ON THE //AFTER YOU CLICK ON

NOTE: That two codes won't work if you do not do the following.On the beginning of the whole code of your project you should have something like this: using System; using System.Collections.Generic; using System.ComponentModel;

using using using using

System.Data; System.Drawing; System.Text; System.Windows.Forms;

Under that write this: using System.Runtime.InteropServices; Then under this: api.mciSendString("set CDAudio door open", null, 127, 0); Or this: api.mciSendString("set CDAudio door closed", null, 127, 0); Write this: public class api { // this api used to send string messege to media control interface decice (mci) // like The cd rom [DllImport("winmm.dll", EntryPoint = "mciSendStringA")] public static extern int mciSendString(string lpstrCommand, string lpstrReturnString, int uReturnLength, int hwndCallback); // this api used to get information about a drive ex: its name, seial number // if this function return zero means that one of the information could not be retrived // so if it is a CD ROM drive and we can't obtain its name ---> CD ROM is empty [DllImport("kernel32.dll", EntryPoint = "GetVolumeInformationA")] public static extern int GetVolumeInformation(string lpRootPathName, StringBuilder lpVolumeNameBuffer, int nVolumeNameSize, int lpVolumeSerialNumber, int lpMaximumComponentLength, int lpFileSystemFlags, string lpFileSystemNameBuffer, int nFileSystemNameSize); //this api get the drive type (0:unknown,1:invalid path,2:removable(floppy,removabledisk),3:fixed(hard disk), //4:remote(network drive),5:CDROM,6: RAM disk) [DllImport("kernel32.dll", EntryPoint = "GetDriveTypeA")] public static extern int GetDriveType(string nDrive); } Then in the form code view,(the place where you will get by clicking two times on the form),write this: string s =""; StringBuilder volumeName = new StringBuilder(256); int srNum = new int(); int comLen = new int(); string sysName = ""; int sysFlags = new int(); int result; string [] logDrives = System.IO.Directory.GetLogicalDrives(); for (int i = 0; i < logDrives.Length; i++) { if (api.GetDriveType(logDrives[i]) == 5) {

s += "Your CD ROM is on drive : " + logDrives[i].ToString() + "\n"; result = api.GetVolumeInformation(logDrives[i].ToString(), volumeName, 256, srNum, comLen, sysFlags, sysName, 256); if (result == 0) s += "there is NO CD in ur CD ROM"; else { s += "There is a CD inside ur CD ROM and its name is " + volumeName; } } }

listView1.LargeImageList = null; listView1.Items.Add("First Item", 0); listView1.Items.Add("Second Item", 1); listView1.Items.Add("Third Item", 2); listView1.Items.Add("Fourth Item", 3); listView1.Items.Add("Fifth Item", 4); listView1.Items.Add("Sixth Item", 5); listView1.Items.Add("Seventh Item", 6); listView1.Items.Add("Eighth Item", 7); listView1.Items.Add("Nineth Item", 8); ListViewItem li = new ListViewItem("Tenth Item", 9); li.Checked = true; li.ForeColor = Color.Blue; listView1.Items.Add(li); //FOR ADDING YOUR OWN ITEMS ON THE LIST VIEW!(Here I added 10 items.Tenth item will have blue letters because I wrote a little different code for that tenth item then for the first nine items. For first nine items I just wrote one line of code and for the tenth item I needed to write more lines of code if I wanted to put his letters in the different color.This code must be written on the place where you get by clicking two times on the form.I am also calling that form code view.It means the same.In this code we won't have any pictures above our text which are that items we added on the list view.Why?Because in the first line of code on the end we wrote the word "null".If we want to have a picture above our item,we will need to put image list on our form.Then in that image list we will go in his properties and in "Images" we

above our item. "null" we the default picture which we example that picture we want to number 0 of code.Of course code instead the option,list view and

will add our picture which we want to be displayed After that,in the first line of code instead the word will write "imageList1".That "imageList1" is of course name of that image list.The number of the first added in the image list is number 0.So in this will be displayed above the first item.If for example display that picture only above our fiveth item,that that picture must be written in the sixth line of number 4 must be deleted.And in the second line of number 0 we must write that number 4.For this image list is needed).

listView1.View = View.LargeIcon; //ITEMS WHICH YOU ADDED ON THE LIST VIEW WILL BECOME LARGE BY CLICKING ON THE BUTTON!(For this option,list view is needed). listView1.View = View.SmallIcon; //ITEMS WHICH YOU ADDED ON THE LIST VIEW WILL BECOME SMALL BY CLICKING ON THE BUTTON!(For this option,list view is needed). listView1.View = View.Tile; //ITEMS WHICH YOU ADDED ON THE LIST VIEW WILL BE IN THE TILE VIEW BY CLICKING ON THE BUTTON!(For this option,list view is needed). listView1.View = View.List; //ITEMS WHICH YOU ADDED ON THE LIST VIEW WILL BE IN THE LIST VIEW BY CLICKING ON THE BUTTON!(For this option,list view is needed).

listView1.BeginUpdate(); listView1.Columns.Add("Name", 200, HorizontalAlignment.Left); ColumnHeader reportDateHeader = new ColumnHeader(); reportDateHeader.Width = 100; reportDateHeader.TextAlign = HorizontalAlignment.Center; reportDateHeader.AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent); reportDateHeader.Text = "Date";

listView1.Columns.Add(reportDateHeader); ColumnHeader authorHeader = new ColumnHeader(2); authorHeader.Width = 100; authorHeader.TextAlign = HorizontalAlignment.Center; authorHeader.AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent); authorHeader.Text = "Author"; listView1.Columns.Add(authorHeader); ListViewItem li1 = new ListViewItem(); li1.ImageIndex = 0; li1.Text = "First Quarter Projects"; li1.SubItems.Add("1/24/2006"); li1.SubItems.Add("Bryan Britz"); listView1.Items.Add(li1); ListViewItem li2 = new ListViewItem(); li2.ImageIndex = 1; li2.Text = "Processed and Procedures"; li2.SubItems.Add("1/25/2006"); li2.SubItems.Add("Mike Thomas"); listView1.Items.Add(li2); ListViewItem li3 = new ListViewItem(); li3.ImageIndex = 2; li3.Text = "Tool Configurations"; li3.SubItems.Add("2/3/2006"); li3.SubItems.Add("Paul Garret"); listView1.Items.Add(li3); listView1.View = View.Details; ListViewItem li4 = new ListViewItem(); li4.ImageIndex = 3; li4.Text = "STARS"; li4.SubItems.Add("23/5/1990"); li4.SubItems.Add("Marin"); listView1.Items.Add(li4); listView1.View = View.Details; listView1.EndUpdate(); //WITH THIS LONG CODE AFTER YOU CLICK ON THE BUTTON,ITEMS WHICH YOU ADDED WILL BE SHOWED IN DETAILS ON THE LIST VIEW!(Here I added 4 items.It has 3 columns and 4 rows because I wrote that in this code.For this option list view is needed).

listView1.BeginUpdate(); ColumnHeader NameHeader = new ColumnHeader(1); NameHeader.Width = 100; NameHeader.TextAlign = HorizontalAlignment.Center;

NameHeader.AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent); NameHeader.Text = "Name"; listView1.Columns.Add(NameHeader); ColumnHeader DateHeader = new ColumnHeader(2); DateHeader.Width = 100; DateHeader.TextAlign = HorizontalAlignment.Center; DateHeader.AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent); DateHeader.Text = "Date"; listView1.Columns.Add(DateHeader); ColumnHeader AuthorHeader = new ColumnHeader(3); AuthorHeader.Width = 100; AuthorHeader.TextAlign = HorizontalAlignment.Center; AuthorHeader.AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent); AuthorHeader.Text = "Author"; listView1.Columns.Add(AuthorHeader); ColumnHeader OtherHeader = new ColumnHeader(4); OtherHeader.Width = 100; OtherHeader.TextAlign = HorizontalAlignment.Center; OtherHeader.AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent); OtherHeader.Text = "TEST"; listView1.Columns.Add(OtherHeader); ListViewItem li1 = new ListViewItem(); li1.ImageIndex = 0; li1.Text = "STARS"; li1.SubItems.Add("23/5/1990"); li1.SubItems.Add("Marin"); li1.SubItems.Add("Sample..."); listView1.Items.Add(li1); listView1.View = View.Details; listView1.EndUpdate(); FUNCTION LIKE THE RPEVIOUS ONE,BUT ADDED A NEW COLUMN TEXT "Sample...". example is much better this option,list

//THIS LONG CODE HAS THE SAME THIS TIME I PUT ONLY ONE ITEM AND I ALSO CALLED "TEST" AND IN WHICH IS WRITTEN THE SO HERE ARE 4 COLUMNS AND 1 ROW!(This and much more simple then the previous one.For view is needed).

listView1.FullRowSelect = checkBox1.Checked; //WHEN YOU PUT THE MARK IN THE CHECK BOX,YOU WILL BE ABLE TO SEE THE WHOLE ROW IN BLUE,NOT JUST THE NAME!(For this option,list view and check box is needed).

listView1.GridLines = checkBox2.Checked; //WHEN YOU PUT THE MARK IN THE CHECK BOX,YOU WILL SEE THE GRID LINES IN THE LIST VIEW!(For this option,list view and check box is needed). listView1.LargeImageList = imageList1; listView1.Items.Add("First Item", 0); listView1.Items.Add("Second Item", 1); listView1.Items.Add("Third Item", 2); //WHEN THE USER CLICKS THE BUTTON,THIS 3 ITEMS TOGETHER WITH PICTURES WILL BE SHOWED ON THE LIST VIEW!(Here I added 3 items and 3 pictures for each of them.So when you click the button,this will be showed.If I for example write this in the form code view,when you turn ON the application,all this 3 items will be immediately showed without clicking the button.For this option,list view and image list is needed). listView1.Clear(); //BY CLICKING ON THE BUTTON,ALL ITEMS IN THE LIST VIEW WILL BE REMOVED!(For this option,list view is needed).

pictureBox1.Image = null; //BY CLICKING ON THE BUTTON,PICTURE IN THE PICTURE BOX WILL BE REMOVED!(For this option, picture box is needed). pictureBox1.Image = Properties.Resources._0; //AFTER YOU CLICK THE BUTTON,PICTURE WHICH YOU CHOSE WILL BE SHOWED IN THE PICTURE BOX!(Be sure the picture you chose is in the Resources/Images and the name of that picture is same like you wrote in this code.Here the name of my picture is "_0".For this option,picture box is needed).

openFileDialog1.Title = "Open File"; openFileDialog1.Filter = "MP3 FILES (*.mp3)|*.mp3|ALL FILES (*.*)|*.*"; openFileDialog1.FileName = ""; openFileDialog1.FilterIndex = 0; openFileDialog1.InitialDirectory = "My Documents";

openFileDialog1.CheckFileExists = true; openFileDialog1.CheckPathExists = true; if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK) { tadaPath = openFileDialog1.FileName; } //WITH THIS CODE AFTER YOU CLICK THE BUTTON, YOU CAN OPEN ANY MP3 MUSIC AND PLAY IT IN THE WINDOWS MEDIA PLAYER!(For this option, open file dialog and windows media player is needed).[This example is better then that one from before]. NOTE:This code won't work if above "public Form1()" you don't write this: string tadaPath = null; Also in the windows media player you must write this: mediaSoundPlayer.settings.autoStart = false; mediaSoundPlayer.URL = @tadaPath; listView1.BeginUpdate(); ColumnHeader NameHeader=new ColumnHeader(1); NameHeader.Width=100; NameHeader.TextAlign=HorizontalAlignment.Center; NameHeader.AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent); NameHeader.Text="Name"; listView1.Columns.Add(NameHeader); ColumnHeader DateHeader=new ColumnHeader(2); DateHeader.Width=100; DateHeader.TextAlign=HorizontalAlignment.Center; DateHeader.AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent); DateHeader.Text="Date"; listView1.Columns.Add(DateHeader); ColumnHeader AuthorHeader=new ColumnHeader(3); AuthorHeader.Width=100; AuthorHeader.TextAlign=HorizontalAlignment.Center; AuthorHeader.AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent); AuthorHeader.Text="Author"; listView1.Columns.Add(AuthorHeader); ColumnHeader OtherHeader=new ColumnHeader(4); OtherHeader.Width=100; OtherHeader.TextAlign=HorizontalAlignment.Center; OtherHeader.AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent);

OtherHeader.Text="TEST"; listView1.Columns.Add(OtherHeader); ColumnHeader LastHeader=new ColumnHeader(4); LastHeader.Width=100; LastHeader.TextAlign=HorizontalAlignment.Center; LastHeader.AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent); LastHeader.Text="FINAL"; listView1.Columns.Add(LastHeader); ListViewItem li1=new ListViewItem(); li1.ImageIndex=0; li1.Text="STARS"; li1.SubItems.Add("23/5/1990"); li1.SubItems.Add("Marin"); li1.SubItems.Add("Sample..."); li1.SubItems.Add("SUCCESS!!!"); listView1.Items.Add(li1); listView1.View=View.Details; ListViewItem li2=new ListViewItem(); li2.ImageIndex=0; li2.Text="MUHAHA"; li2.SubItems.Add("01/2/5000"); li2.SubItems.Add("MIXY"); li2.SubItems.Add("ARGH!!"); li2.SubItems.Add("FAILED!"); listView1.Items.Add(li2); listView1.View=View.Details; listView1.LabelEdit=true; listView1.AllowColumnReorder=true; listView1.EndUpdate(); ON THE BUTTON,5 COLUMNS AND WILL ALSO BE ABLE TO WILL BE ABLE TO option,list view and

//WITH THIS EXAMPLE AFTER YOU CLICK 2 ROWS WILL BE SHOWED,BUT THIS TIME YOU EDIT THE NAME IN THAT 2 ROWS AND ALSO YOU MOVE THE COLUMNS ON OTHER PLACE!(For this context menu strip is needed).

NOTE:Editing the names in that two rows will not work if in the list view you don't add the context menu strip.After you added the context menu strip in that list view,there create any button,(for example "Edit"),and for that button write this code: ListViewItem li0; li0=listView1.FocusedItem; li0.BeginEdit();

if(trackBar1.Value==1) { MessageBox.Show("ONE IS CORRECT!"); } if(trackBar1.Value==2) { MessageBox.Show("TWO IS CORRECT!"); } //AFTER YOU CLICK THE BUTTON,YOU CAN GET TWO MESSAGE BOXES!ONE WILL SAY "ONE IS CORRECT!" AND THE OTHER ONE WILL SAY "TWO IS CORRECT!"!(This is made with track bar.And in it I added 2 values. Value "1" and value "2".I can add them as many as I want in the properties of that track bar,in row which says "Maximum".So in this case I have 3 options free in my track bar because in the "Maximum" I wrote "2" and in the "Minimum" I wrote "0".But of course you can change that so you can have more then even 15 free options in that track bar.So in this example you will have 3 free options.If the bar is on the first line and you click the button, nothing won't happen.But if you scroll the bar on the second line and click the button,you will get a message box with the text "ONE IS CORRECT!".And if you scroll the bar on the third line and click the button,you will get a message box with the text "TWO IS CORRECT!".For second and third line is working because that second line is the value "1" and the third line is the value "2".And we wrote the code only for that two values.Value "1" and value "2". And the value of the first line is of course "0".It always starts from zero/0.If we want to make any function for the first line also,we will just write the code for it one the same way like we wrote it for the second line and third line.For this option,track bar is needed).

webBrowser1.Navigate(textBox1.Text); //AFTER YOU WRITE THE LINK IN THE TEXT BOX AND THEN CLICK THE BUTTON, THAT PAGE WILL BE OPENED IN THE WEB BROWSER! (You can also use something totally else for writing the page links.For example you can use the rich text box also.It doesn't need to be the text box.For this option,web browser and text box is needed). webBrowser1.Stop(); //AFTER YOU CLICK THE BUTTON,THE PAGE ON THE WEB BROWSER WILL STOP LOADING!(For this option,web browser is needed). webBrowser1.Refresh(); //AFTER YOU CLICK THE BUTTON,THE PAGE ON THE WEB BROWSER WILL REFRESH!(For this option,web browser is needed).

NOTE: While turning on the page in the web browser,you also want the there is the progress bar that shows that page loading, you must do the following.Take the status strip and put it in the designer surface and in it add the progress bar. Then go in the events of the web browser and in the "ProgressChanged" write this code: toolStripProgressBar1.Maximum=(int)e.MaximumProgress; toolStripProgressBar1.Value=(int)e.CurrentProgress; MessageBox.Show(webBrowser1.DocumentText,"Page source..."); //AFTER YOU CLICK THE BUTTON,MESSAGE BOX WILL SHOW THE WHOLE SOURCE OF THE PAGE YOU LOADED! (For this option,web browser is needed).

webBrowser1.DocumentText="<html><body><h1>Hello world!</h1><button id='button1'>Fire an Event</button><button onclick='window.external.sayHello()'>Call a Method</button></body></html>"; //AFTER YOU CLICK THE BUTTON, IN THE WEB BROWSER THERE IS GOING TO BE THE TEXT "Hello world!"!(There are also going to be 2 buttons."Fire an Event" and "Call a Method" button.First button will show the message box with the text "Hello from event handler!" and the second

button will show the message box with the text "Hello from script!".For this option, web browser is needed).[This is one line of code.Here it's in two lines because I didn't have enough space to write the whole code in one row]. NOTE:This long one line of code won't work if you don't do the following.Bellow this: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; Write this: using System.Runtime.InteropServices; Then bellow this: namespace Testing { public partial class Form1:Form { public Form1() { InitializeComponent(); } Write this: [ComVisible(true)] public class ScriptMethods { public void sayHello() { MessageBox.Show("Hello from script!"); } } Then in the code view of the form load write this: webBrowser1.ObjectForScripting=new ScriptMethods(); Then in the events of the web browser,in the "DocumentCompleted" write this: HtmlElement elem=webBrowser1.Document.GetElementById("button1"); if(elem!=null) elem.Click+=new HtmlElementEventHandler(elem_Click); And then somewhere at the end of whole code of your project,(or somewhere else),write this: void elem_Click(object sender,HtmlElementEventArgs e) {

MessageBox.Show("Hello from event handler!");

if(e.KeyChar=='\r') webBrowser1.Navigate(textBox1.Text); //AFTER YOU WRITE THE PAGE LINK IN THE TEXT BOX,THE PAGE WILL BE OPENED EVEN IF YOU CLICK THE ENTER BUTTON ON YOUR KEYBOARD!IT WON'T BE NECCESSARY TO CLICK THE BUTTON FOR NAVIGATING THAT PAGE!(This code must be written in the events of that text box,in the "KeyPress".For this option,web browser and text box is needed). ActiveForm.BackColor = Color.Blue; //AFTER YOU CLICK THE BUTTON,THE FORM BACKGROUND COLOR WILL CHANGE TO BLUE COLOR! TopMost=true; //AFTER YOU CLICK THE BUTTON,THE CURRENT WINDOW WILL BE ON THE TOP OF ALL OTHER ACTIVE AND INACTIVE WINDOWS!

Form1.ActiveForm.Text="Example..."; //AFTER YOU CLICK THE BUTTON,THE MAIN TEXT ON THE FORM WILL BE "Example..."! (So for example if the main text on the form is "Application sample",after you click the button that text "Application sample" will be deleted and instead of it it will be written the text "Example...").

Form1.ActiveForm.Size=new System.Drawing.Size(500,500); //AFTER YOU CLICK THE BUTTON,SIZE OF THE FORM WILL CONVERT TO RESOLUTION OF '500x500'!

this.WindowState=FormWindowState.Minimized; BUTTON,FORM WILL MINIMIZE IN THE TASKBAR!

//AFTER CLICKING ON THE

this.WindowState=FormWindowState.Minimized; e.Cancel=true; //IF THE USER CLICKS THE 'X' BUTTON ON THE FORM,THE FORM WON'T CLOSE,IT WILL

written in the events of that "FormClosing" you write only work].

MINIMIZE IN THE TASKBAR!(This code must be form,in the "FormClosing").[Also if in the the second line of this code,the 'X' button won't

Form2 frm=new Form2(); frm.ShowDialog(); //AFTER CLICKING ON THE BUTTON,NEW FORM WILL OPEN AND ALL OTHER FORMS WILL BE TOTALLY INACTIVE!(Only this current form you have turned ON by clicking on the button will be available for use.You will not be able to do anything on any other forms behind this one).

richTextBox1.Copy(); //FOR COPYING THE TEXT FROM THE RICH TEXT BOX! (After you click on the button,the selected text from the rich text box will be copied and you will be able to paste it on any other text areas.For example that text area can be wordpad,notepad and paint.For this option,rich text box is needed). richTextBox1.Cut(); //FOR CUTTING THE TEXT FROM THE RICH TEXT BOX! (After you click on the button,the selected text from the rich text box will be cutted and you will be able to paste it on any other text areas.For example that text area can be wordpad,notepad and paint.For this option,rich text box is needed). richTextBox1.Paste(); //FOR PASTING THE COPIED OR CUTTED TEXT FROM THE RICH TEXT BOX OR ANY OTHER TEXT AREA!(After you click on the button,the selected text from the rich text box or any other text from the text area which you have copied or cutted will be able to be pasted on your rich text box.For example that text area can be wordpad,notepad and paint.For this option,rich text box is needed). richTextBox1.Undo(); //WITH THIS CODE YOU CAN UNDO THE TEXT IN THE RICH TEXT BOX!(For this option,rich text box is needed). richTextBox1.Redo(); //WITH THIS CODE YOU CAN REDO THE TEXT IN THE RICH TEXT BOX!(For this option,rich text box is needed).

richTextBox1.SelectAll(); //FOR SELECTING THE WHOLE TEXT IN THE RICH TEXT BOX!(After clicking on the button,whole written text in the rich text box will be selected and then you can copy or cut that whole text and then paste it in any other text area.For example that text area can be wordpad,notepad and paint.For this option,rich text box is needed).

string one=String.Empty; one=richTextBox1.SelectedRtf; MessageBox.Show(one,"Example text in RTF code..."); //AFTER CLICKING ON THE BUTTON,THE SELECTED TEXT IN THE RICH TEXT BOX WILL BE SHOWED AS RTF CODE IN THE MESSAGE BOX!(For this option,rich text box is needed). string two=String.Empty; two=richTextBox1.SelectedRtf; richTextBox2.Text=two; //AFTER CLICKING ON THE BUTTON,THE SELECTED TEXT IN THE FIRST RICH TEXT BOX WILL BE SHOWED AS RTF CODE IN THE SECOND RICH TEXT BOX!(For this option,2 rich text boxes are needed).

openFileDialog1.Title="Open file..."; openFileDialog1.Filter="Rich text file (*.rtf)|*.rtf|All files (*.*)|*.*"; openFileDialog1.FileName=""; openFileDialog1.FilterIndex=0; openFileDialog1.InitialDirectory="My Documents"; openFileDialog1.CheckFileExists=true; openFileDialog1.CheckPathExists=true; if(openFileDialog1.ShowDialog()==System.Windows.Forms.DialogResult.OK) { richTextBox1.LoadFile(openFileDialog1.FileName); documentTitle=openFileDialog1.FileName; } //AFTER YOU CLICK ON THE BUTTON,YOU WILL BE ABLE TO OPEN ANY TEXT FILE IN THE RICH TEXT BOX!(For this option,rich text box and open file dialog is needed). NOTE: This code won't work if you do not do the following.Above or bellow this: public Form1() { InitializeComponent(); }

Write this: private string documentTitle; saveFileDialog1.DefaultExt=".rtf"; saveFileDialog1.OverwritePrompt=true; saveFileDialog1.Title="Save file..."; saveFileDialog1.Filter="Rich text file (*.rtf)|*.rtf"; if(saveFileDialog1.ShowDialog()==System.Windows.Forms.DialogResult.OK) { richTextBox1.SaveFile(saveFileDialog1.FileName,RichTextBoxStreamType.RichText); documentTitle=saveFileDialog1.FileName; } //AFTER YOU CLICK ON THE BUTTON,YOU WILL BE ABLE TO SAVE THE TEXT FILE ON ANY PLACE ON YOUR COMPUTER!(For this option,rich text box and save file dialog is needed). NOTE: This code won't work if you don't do the following.Above or bellow this: public Form1() { InitializeComponent(); } Write this: private string documentTitle;

richTextBox1.Rtf=""; documentTitle=""; //AFTER CLICKING ON THE BUTTON,WHOLE WRITTEN TEXT IN THE RICH TEXT BOX WILL BE DELETED!(This is usually used when the user wants to start writing the NEW text file.For this option,rich text box is needed). NOTE: This code won't work if you don't do the following.Above or bellow this: public Form1() { InitializeComponent(); } Write this: private string documentTitle;

e.Cancel=true; webBrowser1.Navigate(webBrowser1.StatusText); //THIS CODE WILL PREVENT OPENING LINKS AND OTHER STUFF ON SITES IN THE NEW MICROSOFT INTERNET EXPLORER WINDOW!(When you click on the link on some sites you can notice the that link is mostly opened in the new

Microsoft Internet Explorer window.Thanks to on sites will not be opened in the new opened inside of your own web browser. displayed correctly.This code must be written "NewWindow".For this option,web browser is

this two lines of code,links and other stuff Microsoft Internet Explorer window.It will be Still most of the times site will not be in the events of that web browser,in the needed).

if(openFileDialog1.ShowDialog()==DialogResult.OK) { pictureBox1.Image=Image.FromFile(openFileDialog1.FileName); } //AFTER CLICKING ON THE BUTTON,YOU WILL BE ABLE TO OPEN ANY PICTURE IN THE PICTURE BOX!(For this option,picture box and open file dialog is needed).

if(openFileDialog1.ShowDialog()==DialogResult.Cancel) { MessageBox.Show("You didn't open an image!"); } //AFTER CLICKING ON THE BUTTON,YOU WILL AGAIN OPEN THE SAME WINDOW JUST LIKE IN THE PREVIOUS CODE,BUT THIS TIME AFTER YOU CLICK THE "Cancel" BUTTON,YOU WILL GET THE MESSAGE BOX THAT SAYS "You didn't open an image!"!(For this option, picture box and open file dialog is needed). Console.WriteLine("Example..."); Console.ReadLine(); //AFTER DEBUGGING,YOU WILL GET THE CONSOLE WINDOW WITH THE TEXT "Example..."!(The console won't turn off immediately after debugging because I also wrote this second line of code).

Console.WriteLine(DateTime.Now.ToString()); Console.ReadLine(); //AFTER DEBUGGING,YOU WILL GET THE CONSOLE WINDOW WHICH WILL DISPLAY THE CURRENT DATE AND TIME ON YOUR COMPUTER! int sum; sum=5+20; Console.WriteLine(sum); Console.ReadLine();

//AFTER DEBUGGING,YOU WILL GET THE CONSOLE

WINDOW WITH THE RESULT "25"!(That result has been created by additioning number "5" and number "20"). int sum; int no1=5; int no2=20; sum=no1+no2; Console.WriteLine(sum); Console.ReadLine(); //IN THIS EXAMPLE WE WILL AGAIN GET THE RESULT "25" IN THE CONSOLE WINDOW,BUT ON A LITTLE MORE COMPLICATED WAY!(Here I used 2 variables.First variable is for number "5" and second variable is for number "20").

button3.Visible=false; button1.Visible=true; label2.Visible=true; textBox1.Visible=true; button2.Visible=true; label3.Visible=true; Gen_label2(); //AFTER CLICKING ON THE BUTTON,BUTTON WILL DISAPPEAR AND ALL THIS LINES OF CODE WILL BE EXECUTED!(The button will disappear because that button we click is called "button3".And thanks to the first line of code,that will happen. In short...with this button we start playing the math game). NOTE: Above "public Form1()" write this code: Random randomNo=new Random(); int no1; int no2; string one="+"; Also bellow this: button3.Visible=false; button1.Visible=true; label2.Visible=true; textBox1.Visible=true; button2.Visible=true; label3.Visible=true; Gen_label2(); ...write this: private void Gen_label2() { no1=randomNo.Next(100); no2=randomNo.Next(100); if(radioButton1.Checked) { one="+"; }

else if(radioButton2.Checked) { one="-"; } else if(radioButton3.Checked) { one="*"; } label2.Text=no1+one+no2+"=";

int result=0; if(one=="+") { result=no1+no2; } else if(one=="-") { result=no1-no2; } else if(one=="*") { result=no1*no2; } if(textBox1.Text==result.ToString()) { label3.Text="Correct"; } else { label3.Text="Incorrect"; } //AFTER CLICKING THE BUTTON,THE TEXT IN THE "label3" WILL TELL US IS OUR MATH ANSWER CORRECT OR WRONG BY DISPLAYING THE TEXT "Correct" or "Incorrect" on the "label3"! Gen_label2(); textBox1.Text=""; label3.Text=""; //AFTER YOU CLICK ON THE BUTTON,THE NEXT MATH QUESTION WILL BE DISPLAYED!(The math question will be displayed on the "label2",text in the "textBox1" will be deleted and the text on the "label3" will also be deleted). System.Diagnostics.Process.Start("C:"); HARD DISK PARTITION "C:" WILL BE OPENED! //AFTER THE BUTTON IS CLICKED,YOUR

if(e.Button==MouseButtons.Left)

ReleaseCapture(); SendMessage(Handle,WM_NCLBUTTONDOWN,HT_CAPTION,0); } //WITH THIS CODE YOU CAN MOVE THE FORM BY PRESSING AND HOLDING DOWN YOUR LEFT MOUSE CLICK ANYWHERE ON THE FORM!(This code must be written in the "MouseDown" event of that form). NOTE: This code will not work if you do not do the following.Bellow this: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; Write this: using System.Runtime.InteropServices; Also somewhere in your project write this: public const int WM_NCLBUTTONDOWN=0xA1; public const int HT_CAPTION=0x2; [DllImportAttribute("user32.dll")]public static extern int SendMessage(IntPtr hWnd,int Msg,int wParam,int lParam); [DllImportAttribute("user32.dll")]public static extern bool ReleaseCapture();

SetSuspendState(true,true,false); //AFTER YOU CLICK ON THE BUTTON,YOUR COMPUTER WILL HIBERNATE!(Good example for the hibernation). SetSuspendState(false,true,true); //AFTER YOU CLICK ON THE BUTTON,YOUR COMPUTER WILL HIBERNATE!(Not so good example for the hibernation). SetSuspendState(false,false,true); //AFTER YOU CLICK ON THE BUTTON,YOUR COMPUTER WILL HIBERNATE!(Not so good example for the hibernation). NOTE: Any of this 3 lines of code won't work if you do not do the following.Bellow this: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; Write this: using System.Runtime.InteropServices; Also somewhere in your project write this:

[DllImport("PowrProf")]extern static bool SetSuspendState(bool hibernate,bool force,bool disablewakeup); richTextBox1.Rtf=""; //AFTER CLICKING THE BUTTON,THE WHOLE TEXT IN THE RICH TEXT BOX WILL BE DELETED!(For this option,rich text box is needed). openFileDialog1.Title="Open File"; openFileDialog1.Filter="Rich Text Files (*.rtf)|*.rtf|All Files (*.*)|*.*"; openFileDialog1.FileName=""; openFileDialog1.FilterIndex=0; openFileDialog1.InitialDirectory="MyDocuments"; openFileDialog1.CheckFileExists=true; openFileDialog1.CheckPathExists=true; if(openFileDialog1.ShowDialog()==System.Windows.Forms.DialogResult.OK) { richTextBox1.LoadFile(openFileDialog1.FileName); documentTitle=openFileDialog1.FileName; } //AFTER CLICKING THE BUTTON,YOU WILL GET THE DIALOG WINDOW WITH WHICH YOU WILL BE ABLE TO OPEN ANY TEXT FILE IN YOUR RICH TEXT BOX!(For this option,rich text box and open file dialog is needed). NOTE: This code will not work if you do not do the following.Above this: public Form1() { InitializeComponent(); } Write this: private string documentTitle; saveFileDialog1.DefaultExt=".rtf"; saveFileDialog1.OverwritePrompt=true; saveFileDialog1.Title="Save File"; if(saveFileDialog1.ShowDialog()==System.Windows.Forms.DialogResult.OK) { richTextBox1.SaveFile(saveFileDialog1.FileName,RichTextBoxStreamType.RichText); documentTitle=saveFileDialog1.FileName; } //AFTER CLICKING THE BUTTON,YOU WILL GET THE DIALOG WINDOW WITH WHICH YOU WILL BE ABLE TO SAVE THE TEXT FILE WHICH YOU WROTE IN THE RICH TEXT BOX! (For this option,rich text box and save file dialog is needed). NOTE: This code will not work if you do not do the following.Above this:

public Form1() { InitializeComponent(); } Write this: private string documentTitle; pageSetupDialog1.Document=printDocument1; pageSetupDialog1.PageSettings=printDocument1.DefaultPageSettings; pageSetupDialog1.AllowMargins=true; pageSetupDialog1.AllowOrientation=true; pageSetupDialog1.AllowPaper=true; pageSetupDialog1.AllowPrinter=true; pageSetupDialog1.ShowNetwork=true; pageSetupDialog1.ShowHelp=true; pageSetupDialog1.EnableMetric=false; if(pageSetupDialog1.ShowDialog()==System.Windows.Forms.DialogResult.OK) { printDocument1.DefaultPageSettings=pageSetupDialog1.PageSettings; } //AFTER CLICKING THE BUTTON,YOU WILL GET THE PAGE SETUP DIALOG WINDOW, WHERE YOU WILL BE ABLE TO CONFIGURE THE OPTIONS FOR THE PAPER,PRINTER, ORIENTATION...!(For this option,page setup dialog and print document is needed). printDialog1.Document=printDocument1; if(printDialog1.ShowDialog()==System.Windows.Forms.DialogResult.OK) { printDocument1.DocumentName=documentTitle; printDocument1.Print(); } //AFTER CLICKING THE BUTTON,YOU WILL GET THE PRINT DIALOG WINDOW WITH WHICH YOU WILL BE ABLE TO PRINT THE TEXT WHICH YOU WROTE IN THE RICH TEXT BOX! (For this option,print dialog and print document is needed). [Still does not work properly]... NOTE: This code will not work if you do not do the following.Above this: public Form1() { InitializeComponent(); } Write this: private string documentTitle;

if(fontDialog1.ShowDialog()==System.Windows.Forms.DialogResult.OK) { richTextBox1.SelectionFont=fontDialog1.Font; } //AFTER CLICKING THE BUTTON,YOU WILL GET THE FONT DIALOG WINDOW IN WHICH YOU WILL BE ABLE TO CHANGE THE FONT OPTIONS FOR THE TEXT IN YOUR RICH TEXT BOX!(For this option,rich text box and font dialog is needed). if(colorDialog1.ShowDialog()==System.Windows.Forms.DialogResult.OK) { richTextBox1.SelectionColor=colorDialog1.Color; } //AFTER CLICKING THE BUTTON,YOU WILL GET THE COLOR DIALOG WINDOW IN WHICH YOU WILL BE ABLE TO CHANGE THE COLOR OPTIONS FOR THE TEXT IN YOUR RICH TEXT BOX!(For this option,rich text box and color dialog is needed). Image logoImage; logoImage=Image.FromFile(String.Concat(Environment.GetFolderPath(Environment.Special Folder.MyDocuments),@"\1.bmp")); Clipboard.SetImage(logoImage); richTextBox1.Paste(); Clipboard.Clear(); // AFTER CLICKING THE BUTTON,THE IMAGE FROM THE WRITTEN LOCATION WILL BE DISPLAYED IN THE RICH TEXT BOX!(For this option,rich text box is needed). LockWorkStation(); //AFTER YOU CLICK THE BUTTON,YOUR OPERATING SYSTEM WILL BE LOCKED!(This code will execute the process for switch user). NOTE: This code won't work if bellow this: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; ...you don't write this:

using System.Runtime.InteropServices; Also somewhere in your project code view write this: [DllImport("user32.dll")]public static extern void LockWorkStation(); Application.SetSuspendState(PowerState.Suspend,true,true); CLICK THE BUTTON,YOUR COMPUTER WILL STAND BY! //AFTER YOU

Application.SetSuspendState(PowerState.Hibernate,true,true); //AFTER YOU CLICK THE BUTTON,YOUR COMPUTER WILL HIBERNATE!(This is one of the best codes for the hibernation). ExitWindowsEx(0,0); //AFTER YOU CLICK THE BUTTON,YOUR COMPUTER WILL LOG OFF!(It will log off the current user). NOTE: This code won't work if bellow this: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; ...you don't write this: using System.Runtime.InteropServices; Also somewhere in your project code view write this: [DllImport("user32.dll")]public static extern int ExitWindowsEx(int uFlags,int dwReason);

pictureBox1.BorderStyle=BorderStyle.FixedSingle; //AFTER CLICKING THE BUTTON,THE BORDER STYLE OF THE PICTURE BOX WILL BECOME FIXED SINGLE BORDER STYLE!(For this option,picture box is needed). pictureBox1.BackgroundImage=Properties.Resources._22; //AFTER CLICKING THE BUTTON,THE PICTURE FROM YOUR PROJECT RESOURCES WILL BE DISPLAYED AS THE BACKGROUND IMAGE IN THE PICTURE BOX!(Here the name of my picture from my project resources is "_22".For this option,picture box is needed). string one=String.Empty; one=System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); one+="\\4.jpg";

pictureBox1.ImageLocation=one; //THIS CODE WILL SIMPLY LOAD THE PICTURE FROM YOUR "MyDocumets" FOLDER! (The picture called "4.jpg" which I put in "MyDocuments" folder will be displayed in the picture box after you click the button.For this option,picture box is needed). pictureBox1.ImageLocation="http://www.learnvisualstudio.net/images/lvs_logo_small.gif"; //AFTER YOU CLICK THE BUTTON,THE PICTURE FROM THE INTERNET WEBSITE WILL BE LOADED AND THEN DISPLAYED IN YOUR PICTURE BOX!(For this option,picture box is needed).[Be sure that the picture exists on the selected website].

switch(comboBox1.Text) { case "Normal": pictureBox1.SizeMode=PictureBoxSizeMode.Normal; break; case "Stretch image": pictureBox1.SizeMode=PictureBoxSizeMode.StretchImage; break; case "Autosize": pictureBox1.SizeMode=PictureBoxSizeMode.AutoSize; break; case "Center image": pictureBox1.SizeMode=PictureBoxSizeMode.CenterImage; break; case "Zoom": pictureBox1.SizeMode=PictureBoxSizeMode.Zoom; break; } //WITH THIS CODE AFTER YOU CHOOSE THE ITEM IN THE COMBO BOX AND THEN CLICK IT, THE PICTURE IN THE PICTURE BOX WILL BE DISPLAYED JUST ON THE WAY YOU SELECTED IT!(Here I added 5 items and that are "Normal","Stretch image","Autosize", "Center image" and "Zoom".So for example...if in the combo box you choose the second item which is that "Stretch image" and then click it,the picture in the picture box will be stretched.For this option,picture box and combo box is needed). pictureBox1.ErrorImage=Properties.Resources._1;

pictureBox1.InitialImage=Properties.Resources._2; //AFTER CLICKING THE BUTTON,THE PICTURE BOX WILL BE INITIALIZED!(First line of code will display the picture for error from our project resources if the picture which we are trying to load doesn't exist on the specified location.Second line of code will simply display the picture for loading from our project resources.That picture for loading is displayed in the picture box while the main picture is loading.For this option,picture box is needed). if(tabControl1.SelectedIndex==0) { tabControl1.SelectTab(tabControl1.TabCount-1); } else { tabControl1.SelectTab(tabControl1.SelectedIndex-1); } //AFTER CLICKING THE BUTTON,YOU WILL GO ON THE PREVIOUS TAB!(For this option,tab control is needed). if(tabControl1.SelectedIndex==tabControl1.TabCount-1) { tabControl1.SelectTab(0); } else { tabControl1.SelectTab(tabControl1.SelectedIndex+1); } //AFTER CLICKING THE BUTTON,YOU WILL GO ON THE NEXT TAB!(For this option,tab control is needed).

bool exclusive; Mutex m=new Mutex(true,"INSTANCE",out exclusive); if(exclusive) //THIS CODE WILL ALLOW YOUR APPLICATION TO RUN ONLY ONCE!(If the application is already running and you try to turn it ON again,the application won't turn ON).[This code must be written in the "Program.cs" file]. else { MessageBox.Show("Application is already running!","RUNNING..."); } //THIS CODE WILL GIVE US THE MESSAGE BOX WHICH WILL TELL US THAT THE APPLICATION IS ALREADY RUNNING!(This code is connected with the

written in the "Program.cs" file]. NOTE: This 2 codes won't work if bellow this: using System; using System.Collections.Generic; using System.Windows.Forms; ...you do not write this: using System.Threading;

previous code).[It also must be

To explain this 3 codes that allows your application to run only once,here is the simple code view of the "Program.cs" file: using System; using System.Collections.Generic; using System.Windows.Forms; using System.Threading; namespace WindowsApplication1 { static class Program { /// <summary> /// The main entry point for the application. /// </summary> [STAThread] static void Main() { bool exclusive; Mutex m=new Mutex(true,"INSTANCE",out exclusive); if(exclusive) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()); } else { MessageBox.Show("Application is already running!","RUNNING..."); } } } } NOTE: This code will not work if the option "Optimize code" is enabled in your project properties,in the "Build" section. richTextBox1.LoadFile(@"C:\NAME.rtf"); //THIS CODE WILL LOAD THE RTF TEXT FILE AND SHOW HIS TEXT IN THE RICH TEXT BOX!

richTextBox1.SaveFile(@"C:\NAME.rtf"); //THIS CODE WILL SAVE THE CHANGES FROM THE RICH TEXT BOX IN THE RTF TEXT FILE! NOTE: This two lines of code are very useful if you want to save the changes from the rich text box and then load that changes back to your application.

if(frm.IsDisposed==false) { frm.Show(); } if(frm.IsDisposed==true) { frm=new Form2(); frm.Show(); } //WITH THIS CODE YOU CAN OPEN THE NEW FORM ONLY ONCE NO MATTER HOW MANY TIMES YOU CLICK THE BUTTON! NOTE: This code won't work if above this: public Form1() { InitializeComponent(); } ...you do not write this: Form2 frm=new Form2();

this.SetDesktopLocation(Convert.ToInt32(textBox1.Text),Convert.ToInt32(textBox2.Text)); //AFTER CLICKING ON THE BUTTON,THE DESKTOP LOCATION OF THE FORM IS GOING TO BE SET ON THE CUSTOM DESKTOP LOCATION!(For this option,two text boxes are needed). this.SetDesktopLocation((Int32)Convert.ToInt64(richTextBox1.Text), (Int32)Convert.ToInt64(richTextBox2.Text)); //THIS CODE HAS THE SAME FUNCTION LIKE THE PREVIOUS ONE!(The only difference here is that this code is using 64 bit integer instead of 32 bit integer).[In this code I needed to convert Int32 to Int64 in order to make it work for the SetDesktopLocation method.I converted Int32 to Int64 using "(Int32)" before using "Convert.ToInt64"]. label1.Text=SystemInformation.UserName.ToString(); //AFTER CLICKING THE BUTTON,THE TEXT ON THE LABEL WILL TELL YOU YOUR CURRENT USER NAME THAT IS USED ON YOUR SYSTEM!(For

this option,label is needed).

try { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1());

} catch(Exception) { MessageBox.Show("CATCH has passed..."); } finally { MessageBox.Show("FINALLY has passed..."); } //IN THIS CODE EXAMPLE,IN FIRST 6 LINES OF CODE,THE PROGRAM WILL TRY TO EXECUTE THE 3. 4. AND 5. STATEMENT!IF FOR SOME REASON THEY CANNOT BE EXECUTED,THE 7. 8. 9. AND 10. STATEMENT WILL BE EXECUTED BY THROWING/CATCHING AN EXCEPTION THAT WILL SHOW THE MESSAGE BOX THAT SAYS "CATCH has passed..."!AFTER THAT,THE 11. 12. 13. AND 14. STATEMENT WILL BE EXECUTED BY THROWING/CATCHING THE FINAL STEP THAT WILL SHOW THE MESSAGE BOX THAT SAYS "FINALLY has passed..."!(The final step is executed no matter if the exception was thrown or not).[I took this example from "Program.cs" file].

textBox1.Text="Copying..."; textBox1.Update(); System.IO.File.Copy("C:\\Documents and Settings\\S.T.A.R.S.---UAC\\Desktop\\PCSX2 trailer.avi","C:\\PCSX2 trailer.avi"); textBox1.Text="Done!"; //AFTER CLICKING THE BUTTON,THE FILE "PCSX2 trailer.avi" WILL BE COPIED FROM ONE LOCATION TO ANOTHER!(After you click the button,the text in the text box will be

"Copying...".After will be "Desktop" to text box in copying of second appear.For this use two

the copying is finished,the text in the text box "Done!".In this example I copied the file from disk "C:".The second line of code updates the order to show the text "Copying..." while the that file is in progress.If you do not write that line of code,the text "Copying..." will not option,text box is needed).[Be sure that you slashes for separation instead of one slash].

textBox1.Text="Moving..."; textBox1.Update(); System.IO.File.Move("C:\\Documents and Settings\\S.T.A.R.S.---UAC\\Desktop\\PCSX2 trailer.avi","C:\\PCSX2 trailer.avi"); textBox1.Text="Done!"; //AFTER CLICKING THE BUTTON,THE FILE "PCSX2 trailer.avi" WILL BE MOVED FROM ONE LOCATION TO ANOTHER! (This code executes everything the same like the previous one,only here we are moving the file from "Desktop" to disk "C:" instead of copying the file.For this option,text box is needed). textBox1.Text="Deleting..."; textBox1.Update(); System.IO.File.Delete("C:\\Documents and Settings\\S.T.A.R.S.---UAC\\Desktop\\PCSX2 trailer.avi"); textBox1.Text="Done!"; //AFTER CLICKING THE BUTTON,THE FILE "PCSX2 trailer.avi" WILL BE DELETED FROM YOUR HARD DISK DRIVE! (This code is even easier then the previous two examples.Here I am simply deleting the file from the "Desktop".For this option,text box is needed). textBox1.Text="Copying..."; textBox1.Update(); try { System.IO.File.Copy("C:\\Documents and Settings\\S.T.A.R.S.---UAC\\Desktop\\PCSX2

trailer.avi","C:\\PCSX2 trailer.avi"); } catch(Exception) { MessageBox.Show("The file already exists.It will now be replaced..."); System.IO.File.Copy("C:\\Documents and Settings\\S.T.A.R.S.---UAC\\Desktop\\PCSX2 trailer.avi","C:\\PCSX2 trailer.avi",true); } textBox1.Text="Done!"; //AFTER CLICKING THE BUTTON,THE FILE "PCSX2 trailer.avi" WILL BE COPIED FROM ONE LOCATION TO ANOTHER!(In this example, everything is the same like in the prevoius example for "File.Copy" method,only here I also added an exception.That means the that exception will be thrown if you try to copy the file that already exists.If for example you have already copied the file and want to copy it again with the same name on the same location,you will get the message box which will say "The file already exists.It will now be replaced..." and immediately after you click the OK button, the entire file will be replaced.For this option,text box is needed).[The 10. line of code is same like 5. line of code.The only difference is the 10. line of code on the end has the word "true".That word "true" is the bool value which tells the program to replace the file.If instead of "true" I put "false",the bool value will be oposite and the program will not replace the file.Thanks to this exception, you can replace/recopy the file as many times as you want]. textBox1.Text="Moving folder..."; textBox1.Update(); System.IO.Directory.Move("C:\\Documents and Settings\\S.T.A.R.S.--UAC\\Desktop\\Example","C:\\Example"); textBox1.Text="Done!"; //AFTER CLICKING THE BUTTON,THE FOLDER "Example" WILL BE MOVED FROM ONE LOCATION TO ANOTHER!

(Here I am simply moving the folder that folder needed).

the folder from "Desktop" to my disk "C:".When is moved,all the subfolders and files inside of are also moved.For this option,text box is

textBox1.Text="Deleting folder..."; textBox1.Update(); System.IO.Directory.Delete("C:\\Example",true); textBox1.Text="Done!"; //AFTER CLICKING THE BUTTON,THE FOLDER "Example" WILL BE DELETED FROM YOUR HARD DISK DRIVE!(Here I am just deleting the folder from disk "C:".You can notice that on the end of the third line of code there is a word "true".That word "true" tells the program to delete the entire folder, including all the subfolders and files inside of that folder.If we do not use the word "true" or instead of it we use the word "false",the program will be able to delete only the empty folder.For this option,text box is needed). textBox1.Text="Copying file..."; progressBar1.Minimum=0; progressBar1.Step=10; progressBar1.Maximum=100; progressBar1.Value=0; timer1.Start(); backgroundWorker1.RunWorkerAsync(); BUTTON,THE FILE "Video.avi" WILL BE (Here I am copying the clicking the the file "Copying file..." which will be progress bar

//AFTER YOU CLICK THE COPIED FROM ONE LOCATION TO ANOTHER! file from my "Desktop" to my disk "C:".After button,the file "Video.avi" will start copying.While is copying,the text in the text box will be and there is also going to be the progress bar showing the progress of that file copying.The will be repeating the progress all until copying is

finished. box will be progress bar will "100".This way process will put the code option,text box,

When the copying is finished,the text in the text "Copying finished!" and the progress in the be at his maximum value which is in this case of copying the files is good because the COPYING not pause the rest execution.That's why I have for COPYING files in the background.For this timer and background worker is needed).

NOTE: This code will not work if you do not do the following.In the timer event called "Elapsed" write this code: if(progressBar1.Value!=100) { progressBar1.PerformStep(); } if(progressBar1.Value==100) { progressBar1.Value=0; progressBar1.PerformStep(); } Also in the background worker event called "DoWork" write this code: System.IO.File.Copy("C:\\Documents and Settings\\S.T.A.R.S.--UAC\\Desktop\\Video.avi","C:\\Video.avi",true); And at the end,in the background worker event called "RunWorkerCompleted" write this code: timer1.Stop(); textBox1.Text="Copying finished!"; progressBar1.Value=100; foreach (Process p in Process.GetProcesses(Environment.MachineName)) { if (p.ProcessName.Equals(listBox1.SelectedItem.ToString())) { p.Kill(); break; } } //AFTER CLICKING THE BUTTON,THE SELECTED PROCESS WILL END!(For this option,list box is needed). NOTE: This code will not work if bellow this: using System;

using using using using using

System.Drawing; System.Collections; System.ComponentModel; System.Windows.Forms; System.Data;

...you don't write this: using System.Diagnostics; Also somewhere in your project write this: private void DoRefresh() { listBox1.Items.Clear(); Process[] procs = Process.GetProcesses( Environment.MachineName ); foreach (Process process in procs) { listBox1.Items.Add(process.ProcessName); } } DoRefresh(); REFRESH! //AFTER CLICKING THE BUTTON,ALL PROCESSES WILL

foreach (Process p in Process.GetProcesses(Environment.MachineName)) { if (p.ProcessName.Equals(listBox1.SelectedItem.ToString())) { MessageBox.Show("Process Id: "+p.Id+"\n"+"Process Name: "+ p.ProcessName+"\n"+"Handles Opened by the Process: "+ p.HandleCount+"\n"+"Main Window Title: "+p.MainWindowTitle+"\n"+ "Start Time: "+p.StartTime.ToShortDateString() +" "+ p.StartTime.ToShortTimeString()+"\n"+"Threads Count: "+ p.Threads.Count+"\n"+"Phisical Memory: "+p.WorkingSet/1024+ " K","STATUS"); break; } } //AFTER CLICKING THE BUTTON,THE MESSAGE BOX WILL DISPLAY BASIC INFORMATIONS ABOUT THE SELECTED PROCESS!(This example for displaying informations for the selected process can be made much better and more organized by using controls like labels or rich text boxes in which you can display all the informations about the selected process.For this option,list box is needed). string processName = "notepad"; Process[] processes = Process.GetProcessesByName(processName); foreach(Process process in processes)

process.Kill(); } CALLED "notepad" WILL

//AFTER THE BUTTON IS CLICKED,THE PROCESS END!

NOTE: This code will not work if bellow this: using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; ...you don't write this: using System.Diagnostics; "/n" //THIS IS NOT THE CODE!(This is very useful when writing the text for the message box.With the "/n" function,you can write the text in the new line as many times as you want). System.Object nullObject = 0; string str = ""; System.Object nullObjStr = str; axWebBrowser1.Refresh2(ref nullObjStr); //AFTER CLICKING THE BUTTON,THE PAGE IN THE WEB BROWSER WILL BE REFRESHED!(For this option,web browser is needed). System.Object nullObject = 0; string str = ""; System.Object nullObjStr = str; axWebBrowser1.Navigate(textBox1.Text,ref nullObject,ref nullObjStr,ref nullObjStr,ref nullObjStr); //AFTER YOU WRITE THE LINK IN THE TEXT BOX AND THEN CLICK THE BUTTON,THAT PAGE WILL BE OPENED IN THE WEB BROWSER! (For this option,web browser is needed).

Process[] procs=Process.GetProcesses(Environment.MachineName.ToString()); foreach(Process process in procs) { if(process.MainWindowTitle.Length>0) { listBox1.Items.Add(process.MainModule.ModuleName); } } //AFTER CLICKING THE BUTTON,THE LIST BOX WILL DISPLAY ALL THE PROCESSES THAT ARE CURRENTLY ACTIVE!(For this option,list box is needed). NOTE: To make this code work,under this: using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; ...you need to write this: using System.Diagnostics; foreach(Process procs in Process.GetProcesses(Environment.MachineName.ToString())) { if(procs.MainModule.ModuleName.Equals(listBox1.SelectedItem.ToString())) { procs.Kill(); break; } } //AFTER THE BUTTON IS CLICKED,THE SELECTED PROCESS IN THE LIST BOX WILL END!(This example is useful for ending the selected currently active process.For this option,list box is needed). NOTE: To make this code work,under this: using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; ...you need to write this: using System.Diagnostics;

Process[] procs=Process.GetProcesses(Environment.MachineName.ToString()); foreach(Process process in procs) { try { listBox1.Items.Add(process.MainModule.ModuleName); } catch(Exception) { //No function to execute... } } //AFTER CLICKING THE BUTTON,THE LIST BOX WILL DISPLAY ALL THE CURRENTLY ACTIVE PROCESSES PLUS ALL THE BACKGROUND PROCESSES! (For this option,list box is needed). NOTE: To make this code work,under this: using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; ...you need to write this: using System.Diagnostics; Process[] procs=Process.GetProcesses(Environment.MachineName.ToString()); foreach(Process process in procs) { try { if(process.MainModule.ModuleName==textBox1.Text) { process.Kill(); } } catch(Exception) { //No function to execute... } } //AFTER THE BUTTON IS CLICKED,THE PROCESS NAME WHICH THE USER WROTE IN THE TEXT BOX WILL END!(This is better example for ending the specified process because you must also include the extension together with the

process name.For example:"notepad.exe".If instead you write just "notepad",the process won't end. box is needed). NOTE: To make this code work,under this: using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; ...you need to write this: using System.Diagnostics; contextMenu1.Show(this,new Point(0,0)); CLICK ON THE FORM,THE CONTEXT MENU STRIP WILL LEFT CORNER OF THE FORM!(I wrote this code in the can use this code to display the context menu you want.For example:check box,radio button, option,context menu control is needed).

of the "notepad.exe" For this option,text

//AFTER THE LEFT MOUSE BE SHOWED IN THE UPPER "Click" event of the form.You strip on any possible control picture box...For this

private void menuItem1_DrawItem(object sender, System.Windows.Forms.DrawItemEventArgs e) { Rectangle rc = new Rectangle(e.Bounds.X+1 , e.Bounds.Y+1, e.Bounds.Width-5, e.Bounds.Height-1); e.Graphics.FillRectangle(new SolidBrush(Color.LightGray) , rc); MenuItem s = (MenuItem)sender ; string s1 = s.Text ; StringFormat sf = new StringFormat(); sf.Alignment = StringAlignment.Center ; e.Graphics.DrawString(s1 , new Font("Ariel" ,10), new SolidBrush(Color.Black) , rc , sf ); Console.WriteLine(e.State.ToString()); if ( e.State == (DrawItemState.NoAccelerator | DrawItemState.Selected) || e.State == ( DrawItemState.NoAccelerator | DrawItemState.HotLight) ) { e.Graphics.FillRectangle(new SolidBrush(Color.CornflowerBlue) , rc); e.Graphics.DrawString( s1 , new Font("Veranda" , 10) , new SolidBrush(Color.Black), rc ,sf); e.Graphics.DrawRectangle(new Pen(new SolidBrush(Color.Black)), rc ); } e.DrawFocusRectangle(); e.Graphics.DrawRectangle(new Pen(new SolidBrush(Color.Black), 2 ), rc );

} private void menuItem1_MeasureItem(object sender, System.Windows.Forms.MeasureItemEventArgs e) { e.ItemWidth=75; e.ItemHeight=25; } private void menuItem2_DrawItem(object sender, System.Windows.Forms.DrawItemEventArgs e) { Rectangle rc = new Rectangle(e.Bounds.X,e.Bounds.Y,e.Bounds.Width,e.Bounds.Height); e.Graphics.FillRectangle(new SolidBrush(Color.Black),rc); MenuItem s=(MenuItem)sender; string s1=s.Text ; StringFormat sf=new StringFormat(); sf.Alignment=StringAlignment.Far ; sf.LineAlignment =StringAlignment.Center; Rectangle rcText = rc ; rcText.Width-=5 ; e.Graphics.DrawString(s1 , new Font("Veranda" ,10), new SolidBrush(Color.Blue) , rcText, sf ); e.Graphics.DrawRectangle(new Pen(new SolidBrush(Color.LightGray)), rc ); if ( e.State == ( DrawItemState.NoAccelerator | DrawItemState.Selected)) { e.Graphics.FillRectangle(new SolidBrush(Color.CornflowerBlue) , rc); e.Graphics.DrawString( s1 , new Font("Veranda" , 10 , FontStyle.Bold | FontStyle.Underline) , new SolidBrush(Color.Yellow), rcText,sf); e.Graphics.DrawRectangle(new Pen(new SolidBrush(Color.Black)), rc ); e.DrawFocusRectangle(); } Image useImage = null ; if ( useImage != null ) { SizeF sz = useImage.PhysicalDimension; e.Graphics.DrawImage(useImage, e.Bounds.X+5,( e.Bounds.Bottom + e.Bounds.Top ) /2 - sz.Height/2); } } private void menuItem2_MeasureItem(object sender, System.Windows.Forms.MeasureItemEventArgs e) { e.ItemWidth=100; e.ItemHeight=50; } //THIS IS THE CODE EXAMPLE FOR DRAWING THE TWO MENU ITEMS IN THE CONTEXT MENU CONTROL! (This code might help you to make your own look for the buttons in the context menu control.For this option,context menu control is needed).

NOTE: In the properties of the menu item in the context menu control you must also set to true the option called "OwnerDraw". private void menuItem1_DrawItem(object sender, System.Windows.Forms.DrawItemEventArgs e) { Rectangle rc=new Rectangle(e.Bounds.X,e.Bounds.Y,e.Bounds.Width,e.Bounds.Height); e.Graphics.FillRectangle(new SolidBrush(Color.Black),rc); MenuItem s=(MenuItem)sender; string s1=s.Text; StringFormat sf=new StringFormat(); sf.Alignment=StringAlignment.Near; sf.LineAlignment=StringAlignment.Center; Rectangle rcText=rc; rcText.Width+=5; e.Graphics.DrawString(s1,new Font("Verdana",10),new SolidBrush(Color.Blue),rcText,sf); if(e.State==(DrawItemState.NoAccelerator|DrawItemState.Selected)) { e.Graphics.FillRectangle(new SolidBrush(Color.Yellow),rc); } if(e.State==(DrawItemState.NoAccelerator|DrawItemState.Selected)) { e.Graphics.DrawString(s1,new Font("Verdana",10),new SolidBrush(Color.Red),rcText,sf); } } private void menuItem1_MeasureItem(object sender, System.Windows.Forms.MeasureItemEventArgs e) { e.ItemWidth=75; e.ItemHeight=20; } //THIS IS MUCH BETTER EXAMPLE THEN THE PREVIOUS ONE!(In this example I did the following.When my mouse is not hovering the menu item in the context menu control, the menu item back color is black and the fore color is blue.When I hover the menu item with my mouse,the menu item back color is yellow and the fore color is red.Also I needed to make the correct measurements for the menu item in order to see the text properly.For this option,the context menu control is needed). private void menuItem1_DrawItem(object sender, System.Windows.Forms.DrawItemEventArgs e) { Rectangle rc = new Rectangle(e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height);

e.Graphics.FillRectangle(new SolidBrush(Color.LightGray) , rc); MenuItem s = (MenuItem)sender ; string s1 = s.Text ; StringFormat sf = new StringFormat(); sf.Alignment = StringAlignment.Far ; sf.LineAlignment = StringAlignment.Center; Rectangle rcText = rc ; rcText.Width-=5 ; e.Graphics.DrawString(s1 , new Font("Veranda" ,10), new SolidBrush(Color.Blue) , rcText, sf ); e.Graphics.DrawRectangle(new Pen(new SolidBrush(Color.LightGray)), rc ); if ( e.State == ( DrawItemState.NoAccelerator | DrawItemState.Selected)) { e.Graphics.FillRectangle(new SolidBrush(Color.CornflowerBlue) , rc); e.Graphics.DrawString( s1 , new Font("Veranda",10,FontStyle.Bold | FontStyle.Underline),new SolidBrush(Color.Yellow), rcText,sf); e.Graphics.DrawRectangle(new Pen(new SolidBrush(Color.Black)), rc ); e.DrawFocusRectangle(); } Image useImage = null ; if ( s1 == "Open" ) { useImage = img_fileopen; } if ( s1 == "Close" ) { useImage = img_close; } if ( s1 == "Exit" ) { useImage = img_exit; } if ( s1 == "Security" ) { useImage = img_security; } if ( s1 == "Network" ) { useImage = img_network; } if ( s1 == "About" ) { useImage = img_about; } if ( useImage != null ) { SizeF sz = useImage.PhysicalDimension; e.Graphics.DrawImage(useImage, e.Bounds.X+5,( e.Bounds.Bottom + e.Bounds.Top ) /2 - sz.Height/2); } } //THIS EXAMPLE MIGHT GIVE YOU AN IDEA HOW TO PUT YOUR OWN IMAGE IN THE MENU ITEM OF THE CONTEXT

MENU CONTROL!(For this option,context menu

control is needed).

Image testImage=Image.FromFile("TEST_IMAGE.bmp"); testImage.Save("C:\\SAVED_IMAGE.bmp"); THE BUTTON,THE SAME IMAGE WILL BE SAVED TO ON YOUR HARD DISK DRIVE! ImageFormat format1=ImageFormat.Jpeg; Image image1=Image.FromFile("C:\\FIRST.bmp"); image1.Save("C:\\SECOND.jpg",format1); YOU CAN CONVERT AND SAVE ANY IMAGE FORMAT TO FORMAT!(For example...you can convert and save image or to any other image format such as PNG,GIF NOTE: To make this code work,bellow this: using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; ...write this: using System.Drawing.Imaging;

//AFTER CLICKING ANOTHER LOCATION

//WITH THIS CODE ANY OTHER IMAGE BMP image to JPEG and so on...).