Click here to Skip to main content
15,891,696 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All
I am working on C# windows application where I have to put string array value to data grid view here value is coming but not adding to data grid view cell after run the program the data grid view cell is showing row index = -1 and column index = -1 below
I am giving code


C#
private void Form1_Load(object sender, EventArgs e)
        {
            dgvDisp();
        }
private void dgvDisp()
        {
            DataGridViewTextBoxColumn dgvCol = new DataGridViewTextBoxColumn();
            dgvCol = new DataGridViewTextBoxColumn();
            dgvCol.Width = 65;
            dgvCol.ReadOnly = true;
            dgvCol.SortMode = DataGridViewColumnSortMode.Programmatic;
            dgvCol.HeaderText = "Type";
            dgvBilling.Columns.Add(dgvCol);
        }

                DataGridViewRow r1 = new DataGridViewRow();
                DataGridViewTextBoxCell c1 = new DataGridViewTextBoxCell();
                c1 = new DataGridViewTextBoxCell();
                c1.Value = stringSplitResult[0].ToString();
                r1.Cells.Add(c1);
                dataGridView1.Rows.Add(c1);
Posted
Updated 8-Mar-12 23:07pm
v3
Comments
Ganesan Senthilvel 9-Mar-12 5:09am    
share the complete version of the code

1 solution

you have to bind the datagridview...how the data will be given to the datagridview unless and until it is bind to the source
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900