C#中数据网格视图单元格中的错误 [英] Error in Data grid view cell in C#

查看:94
本文介绍了C#中数据网格视图单元格中的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好
我正在C#Windows应用程序上工作,在这里我必须将字符串数组值放置到数据网格视图中,这里值即将到来,但在运行程序后数据网格视图单元中显示的行索引= -1和列索引未添加到数据网格视图单元中= -1以下
我正在提供代码


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


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);

推荐答案

您必须绑定datagridview ...如何将数据提供给datagridview除非和直到绑定到源
you have to bind the datagridview...how the data will be given to the datagridview unless and until it is bind to the source


这篇关于C#中数据网格视图单元格中的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆