Featured

Adding new Rows to DataGridView on Button Click in C# | CodeWithC# | window based product

learn more about DataGridView.

here we are going to add new rows after every button click. so for that we need to create a function which holds columns and rows which holds data in DataGridView.

Hyper Links contains information from docs.microsoft.com

private void button1_Click(object sender, EventArgs e)
        {
            addRow(textBox1.Text.ToString(),Convert.ToInt32(textBox2.Text));
        }
private void addRow(string name,int roll)
        {
            dataGridView1.Columns.Add("Name","Name");
            dataGridView1.Columns.Add("Roll", "Roll");

            object[] data = { name, roll };
            dataGridView1.Rows.Add(data);
        }
above image contains data which is added to gridView on Add to list Button Click

Check out new one Here: AutoCompleteTextBox with C#

Auto Complete TextBox in C# with DataBase Values | CodeWith C# | Window Based Product

Featured

before copy paste code make sure that, you have used using System.Data.SqlClient; in your code

it is also important to connect data base to your application.

below code is for SQL DataBase

Hyper Links contains information from docs.microsoft.com

void autocomplete_txt()
        {
            textBox1.AutoCompleteMode = AutoCompleteMode.Suggest;
            textBox1.AutoCompleteSource = AutoCompleteSource.CustomSource;
            AutoCompleteStringCollection coll_obj = new AutoCompleteStringCollection();

            SqlConnection conn = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\USERS\ANIKET\DOCUMENTS\JERRYINDIA.MDF;Integrated Security=True;Connect Timeout=30");
            conn.Open();
            SqlCommand cmd = new SqlCommand("select * from bazaar", conn);

            SqlDataReader reader = cmd.ExecuteReader();


            //this is for product name
            int itemCodeOrdinal = reader.GetOrdinal("product_name");
            while(reader.Read())
            {
                string prd_nm = reader.GetString(itemCodeOrdinal);
                coll_obj.Add(prd_nm);
            }

            textBox1.AutoCompleteCustomSource = coll_obj;

            
        }
in above image we can see that when we enter ‘wh’ it shows suggestion from DataBase values

Featured

Socket Programs for client and server in Python

//for client machine
import socket

s=socket.socket()
#portno=13(daytime)||7(eco server)||17(chargen)
port=12345
s.connect(('127.0.0.1',port))
#s.sendall('hello') only for echo
print s.recv(1024)

	
s.close
//for server machine
import socket
s=socket.socket()
print 'connection is established....'
port=1234
s.bind(('',port))

s.listen(5)
print("server is listening")
while True:
	c, addr=s.accept()
	print "accespted connection from ",addr
	c.send("hiii from server....")
	c.close

Data Structure Program 1 | Array | simple array | array using pointers

//by:- aniketkoli183@gmail.com
//for more codes visit here:- http://jerryindia.home.blog

#include<iostream>

using namespace std;


int main()
{
	//simple array
	int arr[5];
	cout<<"Enter data into first array:= ";
	for(int i=0;i<5;i++)
	{
		cin>>arr[i];
	}
	cout<<"Entered data into first array:= ";
	for(int i=0;i<5;i++)
	{
		cout<<arr[i]<<"\n";
	}
	
	
	//array creation with the help of pointers pointer
	int size;
	int *arr1=new int[size];
	cout<<"\nhow much size you need for an array2:=";
	cin>>size;
	
	for(int i=0;i<size;i++)
	{
		cin>>arr1[i];
	}
	cout<<"\nEntered data into second array:= ";
	for(int i=0;i<size;i++)
	{
		cout<<arr1[i]<<"\n";
	}
	return 0;
}

C++ program | Inheritance | Automobile vehicle case study | Class Diagram

//program by:- aniketkoli183@gmail.com
//visit here for more code:- https://jerryindia.home.blog/

#include<iostream>
#include<string>
#define max 10
using namespace std;

class automobile
{
	//private:
	public:	
    //protected:
        string name;
        bool two1,three1,four1;
        int count2;
        int count3;
        int count4;
        
    public:
    	automobile()
    	{
    		count2=0;
        	count3=0;
        	count4=0;
		}
        int getdata()
        {
        	
            cout<<"\nyour are in factory ";
            cout<<"\nEnter company name : ";
            cin>>name;
            cout<<"\nproduction of two wheeler ? [1:yes] [0:no] ";
            cin>>two1;
            cout<<"\nproduction of three wheeler ? [1:yes] [0:no] ";
            cin>>three1;
            cout<<"\nproduction of four wheeler ? [1:yes] [0:no] ";
            cin>>four1;
        }

};

class two : virtual public automobile
{
    protected:
        string modname[max];
        int avg[max],gear[max],price[max],qty2[max];
    public:
        int getdetails()
        {
            cout<<"\nyour are in 2 chaki";
            cout<<"\nEnter model name : ";
            cin>>modname[count2];
            cout<<"\nEnter net average : ";
            cin>>avg[count2];
            cout<<"\nEnter price of "<<modname[count2]<<" : ";
            cin>>price[count2];
            cout<<"\nTotal production of "<<modname[count2]<<" : ";
            cin>>qty2[count2];
            count2++;
        }
        
        int display2()
        {
            cout<<"\n\n...........WELCOME TO FACTORY MANAGEMENT TWO WHEELER SECTION...........\n\n";
            cout<<"Model Name\tNet Avg\tPrice\tProduction\n";
            cout<<count2;
            for(int i=0;i<count2;i++)
            {
                cout<<modname[i]<<"\t\t"<<avg[i]<<"\t\t"<<price[i]<<"\t\t"<<qty2[i]<<endl;
            }         
        }
};

class four : virtual public automobile
{
    protected:
        string modname1[max];
        int avg1[max],gear1[max],price1[max];
        int capacity1[max],qty4[max];
    public:
        int get()
        {
            cout<<"\nyour are in 4 chaki";
            cout<<"\nEnter model name : ";
            cin>>modname1[count4];
            cout<<"\nEnter net average : ";
            cin>>avg1[count4];
            cout<<"\nEnter price of "<<modname1[count4]<<" : ";
            cin>>price1[count4];
            cout<<"\nEnter Fuel capacity of "<<modname1[count4]<<" : ";
            cin>>capacity1[count4];
            cout<<"\nTotal production of "<<modname1[count4]<<" : ";
            cin>>qty4[count4];
            count4++;
        }
        
        int display4()
        {
            cout<<"\n\n...........WELCOME TO FACTORY MANAGEMENT FOUR WHEELER SECTION...........\n\n";
            cout<<"Model Name\tNet Avg\tPrice\tCapacity\tProduction\n";
            for(int i=0;i<count4;i++)
            {
                cout<<modname1[i]<<"\t\t"<<avg1[i]<<"\t\t"<<price1[i]<<"\t\t"<<capacity1[i]<<"\t\t"<<qty4[i]<<endl;
            }         
        }
};

class three: virtual public automobile
{
    protected:
        string modname2[max];
        int avg2[max],gear2[max],price2[max];
        int capacity2[max],qty3[max];
        bool vahtuk[max];
    public:
        int collect()
        {
            cout<<"\nyour are in 3 chaki";
            cout<<"\nEnter model name : ";
            cin>>modname2[count3];
            cout<<"\nEnter net average : ";
            cin>>avg2[count3];
            cout<<"\nEnter price of "<<modname2[count3]<<" : ";
            cin>>price2[count3];
            cout<<"\nEnter capacity of "<<modname2[count3]<<" : ";
            cin>>capacity2[count3];
            cout<<"\nVehicle of type "<<modname2[count3]<<" [1:public ] [0:goods] : ";
            cin>>vahtuk[count3];
            cout<<"\nTotal production of "<<modname2[count3]<<" : ";
            cin>>qty3[count3];
            count3++;
        }
        
        int display3()
        {
            cout<<"\n\n...........WELCOME TO FACTORY MANAGEMENT THREE WHEELER SECTION...........\n\n";
            cout<<"Model Name\tNet Avg\tPrice\tCapacity\tType\tProduction\n";
            for(int i=0;i<count3;i++)
            {
                cout<<modname2[i]<<"\t\t"<<avg2[i]<<"\t\t"<<price2[i]<<"\t\t"<<capacity2[i]<<"\t\t"<<vahtuk[i]<<"\t\t"<<qty3[i]<<endl;
            }         
        }
};

class records:public two, public three, public four
{
    public:
        int display()
        {
            cout<<"\n\n_________________WELCOME TO FACTORY MANAGEMENT_________________\n\n";
            cout<<"Name of Company := "<<name<<"\n";
            if(two1==1)
			{
				display2();	
			}
			else
			{
				cout<<"\n\nPRODUCTION FOR TWO WHEELERS NOT FOUND ACCORDING TO OUR RECORD......\n\n";
			}
			
			if(three1==1)
			{
				display3();	
			}
			else
			{
				cout<<"\n\nPRODUCTION FOR THREE WHEELERS NOT FOUND ACCORDING TO OUR RECORD......\n\n";
			}
			
			if(four1==1)
			{
				display4();	
			} 
			else
			{
				cout<<"\n\nPRODUCTION FOR FOUR WHEELERS NOT FOUND ACCORDING TO OUR RECORD......\n\n";
			}      
        }
};


int main()
{
    records r1[3];
    string cnme;
    cout<<"\n\nENTR DATA FOR THREE COMPANIES......";
    for(int i=0;i<3;i++)
    {
        r1[i].getdata();
    }
    while(true)
    {
    cout<<"\n\n1. SEPARATE ENQUIRY \n2. NET DISPLAY ENQUIRY \n3. PRESS Ctrl+C TO EXIT FROM SYSTEM \nEnter your choice :=";
    int choice;
    cin>>choice;
    switch(choice)
    {
    	case 1:
    		
    		cout<<"\nEnter company name := ";
    		cin>>cnme;
    		
    		for(int i=0;i<3;i++)
    		{
        		if(r1[i].name==cnme)
        		{
        			int p=1;
        			while(p!=0)
        			{
        				cout<<"\n\n1. ADD ENTRY \n2. SEPARATE DISPLAY ENQUIRY \n3. COMPANY DISPLAY ENQUIRY \n4. EXIT \nEnter your choice :=";
        				int cho;
						cin>>cho;
						switch(cho)
						{
							case 1:
								cout<<"1. two wheeler\n2.three wheeler\n3.four wheeler";
								int opt1;
								cin>>opt1;
								if(opt1==1)
								{
									if(r1[i].two1==1)
									{
										r1[i].getdetails();
									}
									else
									{
										cout<<"\n\according to database two wheeler production not selected...";
									}
								}
								if(opt1==2)
								{
									if(r1[i].three1==1)
									{
										r1[i].collect();
									}
									else
									{
										cout<<"\n\according to database three wheeler production not selected...";
									}
								}
								if(opt1==3)
								{
									if(r1[i].four1==1)
									{
										r1[i].get();
									}
									else
									{
										cout<<"\n\according to database four wheeler production not selected...";
									}
								}
								
								break;
								
							case 2:
								cout<<"1. two wheeler\n2.three wheeler\n3.four wheeler";
								int opt;
								cin>>opt;
								if(opt==1)
								{
									if(r1[i].two1==1)
									{
										r1[i].display2();
									}
									else
									{
										cout<<"\n\according to database two wheeler production not selected...";
									}
								}
								if(opt==2)
								{
									if(r1[i].three1==1)
									{
										r1[i].display3();
									}
									else
									{
										cout<<"\n\according to database three wheeler production not selected...";
									}
								}
								if(opt==3)
								{
									if(r1[i].four1==1)
									{
										r1[i].display4();
									}
									else
									{
										cout<<"\n\according to database four wheeler production not selected...";
									}
								}							
								break;
								
							case 3:
								r1[i].display();
								cout<<"\n..............................................................";
								r1[i].display();
								cout<<"\n..............................................................";
								r1[i].display();
								break;
								
							case 4:
								p=0;
								break;
							default:
								cout<<"\n\nINVALID SELECTION.....";
								break;
						}
					}
        				
				}
    		}
    		break;
    	
    	case 2:
    		for(int i=0;i<3;i++)
    		{
        		r1[i].display();
    		}
    		break;
    		
    	default:
    		cout<<"\n\nINVALID SELECTION.....";
    		break;
	}
	}
    return 0;
}
class diagram

C program for Conversion of Dotted Decimal IP to Binary IP address..

//By:- aniketkoli183@gmail.com
//visit:-  https://jerryindia.home.blog/ 


#include

int main()

{

 int arr[4],ip1[8],ip2[8],ip3[8],ip4[8];

 int i,j,k,l;

 for(i=0;i<8;i++)

 {

  ip1[i]=0;

  ip2[i]=0;

  ip3[i]=0;

  ip4[i]=0;

 }

 

 printf("Enter IP address := ");

 scanf("%d%d%d%d",&arr[0],&arr[1],&arr[2],&arr[3]);

 printf("\nEntered IP address is := ");

 for(i=0;i<4;i++)

 {

  printf("%d",arr[i]);

  printf(".");

 }

 printf("\n");

 int temp=0,temp1=0,temp2=0,temp3=0;

 temp=arr[0];

 temp1=arr[1];

 temp2=arr[2];

 temp3=arr[3];

 

 i=7;

 printf("\nConverted Binary IP address is := ");

 

 //for first octate

 while(temp>0)

 {

  

  ip1[i]=temp%2; 

  temp=temp/2; 

  i--;

 }

 for(i=0;i<8;i++)

 {

  printf("%d",ip1[i]);

 }

 printf(".");

 

 //for second octate

 j=7;

 while(temp1>0)

 {

  

  ip2[j]=temp1%2; 

  temp1=temp1/2; 

  j--;

 }

 for(i=0;i<8;i++)

 {

  printf("%d",ip2[i]);

 }

 printf(".");

 

 //for third octate

 k=7;

 while(temp2>0)

 {

  

  ip3[k]=temp2%2; 

  temp2=temp2/2; 

  k--;

 }

 for(i=0;i<8;i++)

 {

  printf("%d",ip3[i]);

 }

 printf(".");

 

 //for fourth octate

 l=7;

 while(temp3>0)

 {

  

  ip4[l]=temp3%2; 

  temp3=temp3/2; 

  l--;

 }

 for(i=0;i<8;i++)

 {

  printf("%d",ip4[i]);

 }

}
output of program