Hi,
I am working in C# windows application
&
I have one combo box which have the list of items. and one datagridview. now I want to add new rows as i select the combo box items. The number of row add in datagridview till i select the items from combo box.

like for billing system.

Sorry I don't have any idea for code..
So I didn't post code for that can any one solve this.

You can use datatable for that here is sample code to add columns and row in datagridview here i am used checkbox and link columns you can use what u want.

//Add columns dynamically  to gridview
            dtgomr.Columns.Insert(0, new DataGridViewTextBoxColumn());
            dtgomr.Columns.Insert(1, new DataGridViewCheckBoxColumn());
            dtgomr.Columns.Insert(2, new DataGridViewCheckBoxColumn());
            dtgomr.Columns.Insert(3, new DataGridViewCheckBoxColumn());
            dtgomr.Columns.Insert(4, new DataGridViewCheckBoxColumn());
            dtgomr.Columns.Insert(5, new DataGridViewLinkColumn());
            //Data Binding 
            DataTable dt = new DataTable();
            dtgomr.Columns[0].Width = 35;
            dtgomr.Columns[1].Width = 25;
            dtgomr.Columns[2].Width = 25;
            dtgomr.Columns[3].Width = 25;
            dtgomr.Columns[4].Width = 25;
            dtgomr.Columns[5].Width = 40;

            dtgomr.Columns[1].HeaderText = "A";
            dtgomr.Columns[2].HeaderText = "B";
            dtgomr.Columns[3].HeaderText = "C";
            dtgomr.Columns[4].HeaderText = "D";

 for (int r = 0; r < (Your combo value); r++)
                {
                    DataRow dtr = dt.NewRow();
                    dt.Rows.Add(dtr);
                }

                datagridview1.DataSource = dt;

don't forget to clear rows each time while you select combobox.

Hope this will help you.
Cheers.....

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.