Skip to main content

Posts

Showing posts from August, 2017

Add, remove, search an item in listview in C#

Below is the C# code which will help you to add, remove and search operations on listview control in C#. Below is the design view of the project: Below is the source code of the project: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace Treeview_control_demo {     public partial class Form2 : Form     {         public Form2()         {             InitializeComponent();             listView1.View = View.Details;                   }         private void button1_Click(object sender, EventArgs e)         {             if (textBox1.Text.Trim().Length == 0)...

multibagger NSE BSE

Hello all, I am sharing the google Sheet which contains stock scripts which will be immensely valuable for you. I have applied so many google formuales in order to create the same. Believe me it will give you idea when to buy a stock among a list of stocks. It will show you the low level stock price to buy among the list. Below is the updated stock list by me. https://docs.google.com/spreadsheets/d/1yTxIIuJ5Hyw8TqqcLwkL8K0NJDaPio4kdPUm6UUBbnw/edit#gid=0   Your kind sugestions will help me to grow this list more beneficial to all of you. In future I will create and share sectoral wise stock list and publish publicly.   Believe me this is going to most beneficial to all invester and traders. Again any suggestions from your side are most welcome. Steps to use: 1) first cloumn is the script code which is the script code of nse or bse. 2) Scriptname is the name of the BSE/NSE stock. 3) Investment is the actual amount you have invested. 4) Shares is the number of sh...

Treeview example in C# 2

Below is the code which shows treeview control demo in c#. It has a treeview control. If we select any node on treeview, the label is showing corresponding selected name of the node of treeview. Below is the design view of the project: Below is the source code of the project: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace Treeview_control_demo {     public partial class Form1 : Form     {         public Form1()         {             InitializeComponent();             treeView1.Nodes.Clear();             TreeNode root = new TreeNode("India");             TreeNode s1 = new TreeNode("MH");     ...

Employee Salary calculator windows project in C#

Below is the window project in c# which calculates the net salary of the employee. It takes employee id, name and designation as input and calculates the salary according to the designation of the employee. The project has static data. I have not implemented a database for storing data. in future will share projects who will have database to store data. Thanks for visiting my blog. I will try to make this blog is best source of learning for you.     Below is the design view of the project: Below is the source code of the project: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace Employee_Salary_calculator_demo {     public partial class Form1 : Form     {         int empno;         String name;       ...

Treeview control demo in C#

Below is the code which shows treeview control demo in c#. It has a treeview control and a label. If we select any node on treeview, the label is showing named corresponding selected name of the node of treeview. Below is the design view of the project: Below is the source code of the project: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace Treeview_control_demo {     public partial class Form1 : Form     {         public Form1()         {             InitializeComponent();         }         private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)         {             label1.Text = treeVie...

RGB Color Demo in C# using scrollbar as a slider horizontally

Below is the project which contains 3 horizontal scrollbars if we slides the scrollbars the background color of the form is changing accordingly. first scrollbar is adding red color, second adding green and third one adding blue upon scrolling or sliding. Take 3 horizontal scrollbars and assign them maximum value of 255(from 0) to each one. Below is the designer view of the project: Below is the source code of the project: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace Color_RGB_demo {     public partial class Form1 : Form     {         public Form1()         {             InitializeComponent();                   }         public...

Student Marksheet with grades windows form project in C# demo

Student Mark-sheet windows form in C# demo Below is the program which takes students name, marks of 6 subjects as an input. After a button click it will display result either PASS, FAIL or ATKT (for 2 backlogs).  Below is the design view of the project: Below is the windows C# source code: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace marksheet_demo {     public partial class Form1 : Form     {         int m1, m2, m3, m4, m5, m6, total;         float per;         String name, grade, result;         public Form1()         {        ...

Multibagger stocks

Hello all, I am sharing the google Sheet which contains stock scripts which will be immensely valuable for you. I have applied so many google formuales in order to create the same. Believe me it will give you idea when to buy a stock among a list of stocks. It will show you the low level stock price to buy among the list. https://docs.google.com/spreadsheets/d/1yTxIIuJ5Hyw8TqqcLwkL8K0NJDaPio4kdPUm6UUBbnw/edit#gid=0   Your kind sugestions will help me to grow this list more beneficial to all of you. In future I will create and share sectoral wise stock list and publish publicly.   Believe me this is going to most beneficial to all invester and traders. Again any suggestions from your side are most welcome. Steps to use: 1) first cloumn is the script code which is the script code of nse or bse. 2) Scriptname is the name of the BSE/NSE stock. 3) Investment is the actual amount you have invested. 4) Shares is the number of share you are holding 5) Netprice is your...

Mini C# project of math game demo

Mini project of math game in C# demo Assignment: Below is the very small project. It contains a button after clicking that it will internally generate a random number between 1 to 100 range only and we have to guess that number and if we success it will show the number of attempts we required to guess that number. Below is the design view of the projects contains two screens: HERE IS THE CODE: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace generate_random_number_demo {     public partial class Form1 : Form     {         int x = 0, att = 0;         Random r1 = new Random();         public Form1()         {             InitializeComponent();   ...

Add or remove items to listbox provided no duplicates in c#

Add or remove items to listbox provided no duplicates in c# Assignment:  Below is the code which takes an String input through textbox and it will add that string to listbox. If we tried to insert duplicate item it will generate an error mentioning that item already present. Please do not enter duplicates. One limitation of this project is that the string is case insensitive means, it cannot make a difference between uppercase and lowercase letters. You have to put exact equal string in order to trace the duplicates. I will later will add code which will also have logic for case sensitivity. Thanks. Here is the Design view: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace Listbox_add_remove_item_demo {     public partial class Form1 : Form   ...

Radio button basic operation in C# demo

Below is the windows form application which have four radio buttons. Each having its speciality. Let's see this with grammatically. Below is the design view of the project: Here is the source code for the above project: Form1.cs: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace basic_opr_radio_btn_demo {     public partial class Form1 : Form     {         public Form1()         {             InitializeComponent();         }         private void Form1_Load(object sender, EventArgs e)         {                   }         private void radioButton5_CheckedChanged(object ...

Basic windows form login in C# demo

Below is the code which accepts username and password from the user and login if successful else displays error in message box. Here are the design view of the project: Login Screen: after successful login it will opens another form mentioned below: Here is the code for the above project: 1) Program.cs: using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using System.Windows.Forms; namespace basic_opr_windows_app_demo1 {     static class Program     {         ///         /// The main entry point for the application.         ///         [STAThread]         static void Main()         {             Application.EnableVisualStyles();             Application.SetCompatibleTextRenderingDefault(false);     ...

Basic windows form calculator in C# Demo

Below is the program that will perform basic arithmetic operations inn C# using windows form application Below is the design view of the project. and here is the source code for the same: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace basic_opr_windows_app_demo1 {     public partial class Form1 : Form     {         public Form1()         {             InitializeComponent();         }         private void textBox2_TextChanged(object sender, EventArgs e)         {         }         private void button1_Click(object sender, EventArgs e)         {        ...

Excel to PDF converter in Selenium with java Demo

package excel2pdfDemo; import java.io.FileInputStream; import java.io.*; import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.hssf.usermodel.HSSFSheet; import org.apache.poi.ss.usermodel.*; import java.util.Iterator; import com.itextpdf.text.*; import com.itextpdf.text.pdf.*; public class Excel2pdf {          public static void main(String[] args) throws Exception{                 FileInputStream input_document = new FileInputStream(new File("D:\\APCH.xls"));                 // Read workbook into HSSFWorkbook                 HSSFWorkbook my_xls_workbook = new HSSFWorkbook(input_document);                 // Read worksheet into HSS...

Create a subdirectory using directoryinfo class in C# Demo

Below is the program which creates a subdirectory using directoryinfo class and displays its type to console windows in c#. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace File_directory_demo {     class Program     {         static void Main(string[] args)         {             System.IO.DirectoryInfo d1 = new System.IO.DirectoryInfo(@"e:\Demo2");             d1.CreateSubdirectory("Demo3");             Console.Write(d1.GetType());                       Console.ReadKey();         }     } }

Create a directory and its operations in C# Demo

Below is the program which creates a directory, moves a directory and deletes a directory in c#. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace File_directory_demo {     class Program     {         static void Main(string[] args)         {             System.IO.Directory.CreateDirectory(@"e:\a1\a2\a3\a4");             System.IO.Directory.Move(@"e:\a1\a2\a3", @"e:\Demo2");             System.IO.Directory.Delete(@"e:\Demo1");                         Console.ReadKey();         }     } }

Display file creation date and time in C# Demo

Below is the program which displays the date and time at which the file is created in c#. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace File_directory_demo {     class Program     {         static void Main(string[] args)         {             System.IO.File.Create("e:\\abc.txt");             DateTime dt;             dt=System.IO.File.GetCreationTime("e:\\abc.txt");             Console.WriteLine("File creation time is: {0}",dt.ToString());                       Console.ReadKey();         }     } }

Foreach loop in C# Demo

Below is the program which shows how to use foreach loop in c#. Syntax : foreach(datatype alias in variable_to_iterate) using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace File_directory_demo {     class Program     {         static void Main(string[] args)         {             System.IO.File.Create("e:\\abc.txt");             System.IO.File.AppendAllText("e:\\abc.txt", "\n I am living in ahmednagar");              byte[] b=System.IO.File.ReadAllBytes("e:\\abc.txt");               foreach(char c in b)                {                    Console.Write(c);                } ...

Create a file and append into it in C# Demo

Below is the code which will demonstrate how to append the contents to the file. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace File_directory_demo {     class Program     {         static void Main(string[] args)         {             System.IO.File.Create("e:\\abc.txt");             System.IO.File.AppendAllText("e:\\abc.txt", "\n I am living in ahmednagar");              byte[] b=System.IO.File.ReadAllBytes("e:\\abc.txt");               for(int i=0;i                {                    Console.Write((char)b[i]);                }             ...

Create a file and write into it in C# Demo

Below is the program which will create a file and write into it. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace File_simple_demo {     class Program     {         static void Main(string[] args)         {             //System.IO.File.Create("e:\\abc.txt");             System.IO.Directory.CreateDirectory(@"e:\a1\a2\a3");             if (System.IO.File.Exists(@"e:\abc.txt"))             {                 Console.WriteLine("File Already exists");             }             else             {                 String str = "My Name is Scott, I am w...

Multiple user defined exceptions demo in c#

Multiple user defined exceptions demo in c# Assignment : Below is the multiple user defined exceptions master program which takes a number as an input from the user and performs following operations on it as: 1) If number is > 100 throw number too large exception. 2) If number is < 0 throw negative number exception. 3) If number is even throw even number exception. 4) If number is zero throw number too zero exception. otherwise calculates the sum of the digits of a given number. Ex. 1233 = 1 + 2 + 3 + 3 = 9 Solution: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace exception_master_demo {     class Greaterthanzero :Exception     {         public override string ToString()         {             return "Number greater than zero....";         }     } ...

User defined exception example with power of a number demo in C#

Below is the code which takes two parameters x and y and it calculates the power of a number(x raise to y). If we pass y as a negative number as an argument it will throw a user defined exception. For this we have created a class which inherits an "exception" superclass and it contains an overriden tostring() method to print the user defined exception message. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Exception_inheritance_demo_2 {     class MyEx : Exception     {         public override string ToString()         {             return "Negative number not allowed";         }     }     class A     {         void pow(int x, int y)         {             if (y < 0)   ...

Exception with factorial example demo in C#

Below is the code which calculates the factorial of a number. If we pass a negative number as an argument it will throw a user defined exception. For this we have created a class which inherits an "exception" superclass and it contains an overriden tostring() method to print the user defined exception message. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Exception_inheritance_demo {     class MyEx : Exception     {         public override string ToString()         {             return "No not allowed";         }           }     class A     {         void facto(int n)         {             if (n < 0)                 thr...

Power of number exception demo in C#

Assignment : below is the program which calculates power of any number. If we pass a negative power number it will generate an exception. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Exception_Power_demo {     class F1     {         void pow(int x, int y)         {             if (y < 0)                 throw new FormatException();             int p = 1;             while (y > 0)             {                 p = p * x;                 y--;             }             Console.WriteLine("power{0}", p);       ...

Factorial exception demo in C#

Assignment : below is the program which calculates a factorial of a given positive number. If we pass a negative number it will generate an exception. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Exception_factorial_demo {     class F1     {         void facto(int x)         {             if (x < 0)                 throw new FormatException();             int f = 1;             while (x > 0)             {                 f = f * x;                 x--;             }             Console.WriteLine("factorial{0}", f);   ...

Exception demo in C#

Below is the code which demonstrates how exception is handled in C# using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Exception_Demo {     class Program     {         int x, y, z;         Program()         {             x = y = z = 0;         }         static void Main(string[] args)         {             Program p = new Exception_Demo.Program();             try             {                 p.x = Int32.Parse(args[0]);                 p.y = Int32.Parse(args[1]);                 p.z = p.x / p.y;     ...

Override in built ToString() method with Student class in C# example

Below is the small source code which demonstrate how to override in built ToString() method with Student class in C# which is mostly used in exception handling. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace override_student_tostring_demo {     public class Student     {         int rno, std;         float per;         string name;         Student()         {             rno = std = 0;             name = "";             per = 0.0f;         }         public Student(int rno, string name, int std, float per)         {             this.rno = rno;             this....

Override in built ToString() method with employee class in C# example

Below is the small source code which demonstrate how to override in built ToString() method with employee class in C# which is mostly used in exception handling. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace override_tostring_employee_demo {     public class Emp     {         int eno, sal;         string name;         Emp()         {             eno = sal = 0;             name = "";         }       public Emp(int rno, string name,int sal)         {             this.eno = rno;             this.sal = sal;             this.name = name;         }      ...