c# codes

Download C# CODES

If you can't read please download the document

Upload: brighter777

Post on 23-Nov-2014

149 views

Category:

Documents


0 download

TRANSCRIPT

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..."); SAYS SOMETHING! textBox1.Text = "write text"; CLICKING THE BUTTON! this.Dispose(); this.Close(); //FOR MESSAGE BOX THAT

//FOR SHOWING THE TEXT IN THE TEXT BOX BY

//FOR CANCEL! //FOR CLOSE!

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

//FOR GOING ON ANY SITE THROUGH

//FOR NEW FORM!

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

//FOR SHOWING THE TEXT

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

THE TEXT YOU WROTE!

CANCEL BUTTON TOGETHER WITH (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(); SOUND OR MUSIC FROM THE PATH!

//FOR PLAYING ANY

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!"); ///"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"); //FOR SHOWING THE MESSAGE BOX THAT SHOW'S THE 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}! } } WROTE IN THE CONSOLE!(The do it). ", name); //FOR SHOWING THE TEXT YOU console won't turn off until you don't [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(); } } } IN THE CONSOLE!(The console previous code way]. //FOR SHOWING THE TEXT YOU WROTE won't turn off until you don't do it). [This code shows the same thing like the but on a little more simple and better

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; YOU REMOVE THE MOUSE FROM THE BUTTON, YOU HAVE CHOOSEN BUTTON!(You must do button). if (button1.Dock == DockStyle.Fill) { button1.Dock = DockStyle.None; } else { button1.Dock = DockStyle.Fill; } CLICKING ON IT!(The button will this option,table //AFTER PREVIOUS PICTURE WHICH WILL BE SHOWED ON THAT this in the events of that

//FOR STRETCHING THE BUTTON BY become bigger after you click on it.For 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 OPTION!(Also this same code can function for more "button1",there will box you wrote and if example "YO!",when message box will be events and in on that "button2" you wrote and the like the text in

WHICH YOU WERE USING FOR THIS be used in events so you have the same buttons.For example when you click the of course be the name of the message text in the name of that button is for you click on that button the text in the "YO!".For "button2",select it and go in his "Click" choose "button1".After you click the name of the message box will be what text in that message box will be the same 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 BUTTON!(For this option, box is needed).

AFTER YOU CLICK ON THE open file dialog and rich text

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

box is

dialog and rich text 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; } SEQUENCES FOR THE BUTTONS PREVIOUS CODE!(With this you added],on 4 are:bottom up,left to this option,

= FlowDirection.BottomUp; = FlowDirection.LeftToRight; = FlowDirection.TopDown; = FlowDirection.RightToLeft; //THIS CODE IS FOR 4 DIFFERENT WHICH YOU ADDED THANKS TO THE code you can put the buttons,[which different sequences.And that right,top down and right to left.For

needed). if (checkBox1.Checked == true) flowLayoutPanel1.WrapContents = true; else flowLayoutPanel1.WrapContents = false; BUTTONS YOU ADDED ON THE FORM,THEY FORM,IF THERE IS ENOUGH PLACE (That will happen if you this option,check box

combo box and flow layout panel is

//WITH THIS CODE,ALL WILL ALL BE SHOWED ON THE FOR THEM IN FLOW LAYOUT PANEL! put the mark in that check box.For 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 ICON 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: process1.Kill();

Write this: 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); "Freeman"! string car = "Hello"; MessageBox.Show(car); string car; string bike; car = "Hello man!!"; bike = "What's up?!"; MessageBox.Show(car + bike); What's up?!"!

//STRING THAT SHOWS THE WORD

//STRING THAT SHOWS THE WORD "Hello"!

//TWO STRINGS THAT SHOWS "Hello man!!

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 you today? I am

MESSAGE BOX "Hello.How are fine...and you?"!

splitContainer1.IsSplitterFixed = true; (With this code,after you click resize the split write the word container.For

//FOR FIXING THE SPLITTER! on the button,you won't more be able to container.But if instead word "true" you "false" you will be able to resize the split this option,split container is needed). //FOR SETTING THE SPLITTER the split container will become wider on number "100" so the split container will right enough,but if the number is 10,split become wider on the right just a little.For container is needed).

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

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

//FOR SETTING THE SPLITTER split container will go on the left,where is form.Here is number "30" so the split far from the left end of your form.But if you or more,the split container won't be close to 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; //FOR STARTING THE TIMER BY CLICKING THE BUTTON!(For the basic timer). timer1.Enabled = false; THE BUTTON!(For the basic timer). //FOR STOPING THE TIMER BY CLICKING

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 place where you get after you click two times on the form and it also must be written on the place where you get after you click on the timer two times.This is usually used for the special timer which you take from your toolbox if you added it from the "General" section. For this option,timer is needed). timer1.Start(); BUTTON!(For the special timer). timer1.Stop(); BUTTON!(For the special timer). //FOR STARTING THE TIMER BY CLICKING THE

//FOR STOPING THE TIMER BY CLICKING THE

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") { MessageBox.Show("YOU PICKED GRANT!!!"); } else { MessageBox.Show("You didn't choose an option!"); } } 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!

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 wrote the word I wanted.In this case that are "Marin","Emil" and "Dad".In the last row I added a message box which will say "Marin".It will say "Marin" because in the second row the number is 0.So I also wrote it in the message box together with my string name.So the message box with the text "Marin" will appear by clicking on the button.Now...the important thing is if the number in the first row is 3 then you must not add more then 3 strings for the text. Also first number is always 0.So if in the first row is number 3,then you can add maximum 3 strings starting from number 0.I mean on this: "0" then "1" and the last one is "2".So the number of your strings must not contain the same or higher number then the number in the first row.Also number must not be less then number 0.So for example if in the first row I write the number 9,then you can add maximum 9 new strings starting from the number 0). 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

first,number 1 is the second the number 0 instead be "Marin").

like I said before,number 0 is the and so on...so if in the second row I write number 1,the text in the message box will

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 will say one word.It depends what sequence your words has.Here I wrote 4 words and that are "Marin","Emil","Vesna" and "Bob".So after you click on the button,the first message box with the text "Marin" will be showed.After you click on the "OK" button on that message box,there will automatically be a second message box with the text "Emil".Third message box will show the 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 BUTTON,THE MESSAGE BOX WILL WILL BE "The final value it's set to must write number that,by clicking on message box which the "i" is the text box you higher number because value which if you write 9,message box will say you set number -9,and value in you must write example number -4 or box is needed).

6 AND THEN PRESS THE BE SHOWED AND THE TEXT is: 6"!(If that "i" is number 0 and "++" then in the text box you 0 or any higher number.After the button there will be a will say the value.But if you write for example number 9,then in must write number 9 or any "i" is set the he is less then the we are writing in the text box.So number 4 and the "i" is the value is 9.Also for example if "int i = -9;" so then "i" is if he is set the he is less then the the text box then in the text box number -9 or higher.For number 2.For this option,text

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; } } //WITH THIS CODE,AFTER YOU CHOOSE THE ITEMS IN THE LIST BOX YOU WANT AND THEN CLICK THE BUTTON,THAT ITEMS WILL ALL BE EXECUTED!(In the list box choose one or more options and then click the button.After that all options you chose,will be executed.Here "i" is number 0 and it's set the he is less then the value in the list box.You can see that in the first row.So that means the you must choose at least one item from the list box and then click on the button,otherwise if you don't choose anything and you click the button,nothing won't happen because we chose 0 items and the "i" is 0.And "i" which is 0 is equale to 0 items we selected in the list box.But if "i" is number 1 and we selected four items in the list box,3 of them will be executed and fourth won't be executed because that number 1 is set the he is less then the value in the list box.In this case value in the list box is 4.For example if in the list box we have 5 items and we chose them all and if "i" is number 3,by clicking the button only 2 items of all 5 items will be

executed.That example best solution is to choose every item executed.If "i" is in the list box and this option,list box

will work if "i" is also set to "++".But the the "i" is number 0.Then you don't need in the list box so the only few of them be number 0,then you can choose any item that item you chose will be executed.For 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()); 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()); }

//BY CLICKING ON THE 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()); WILL GET THE SAME BY CLICKING ON THE the same code bellow

//IN THIS EXAMPLE YOU BUTTON!(Also note the you must write 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); //BY CLICKING ON THE BUTTON,YOU WILL GET THE MESSAGE BOX WITH THE TEXT "Oldsmobile"!(One example).[If you understand the strings, then you should understand this]. First myFirst = new First(); myFirst.Make = "Oldsmobile"; myFirst.Model = "Cutlas Supreme"; 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 {