1.编辑行中内容

 this.dataGridView1.Rows[GlobleVariable.VarNum].Cells[1].Value = value1;

2.删除指定行

dataGridView1.Rows.Remove(dataGridView1.SelectedRows[0]);

3.设置成选中整行:选择模式设置成FullRowSelect
在这里插入图片描述
4.查找指定内容

            for (int i = 0; i < dataGridView1.Rows.Count; i++)
            {
                for (int j = 0; j < dataGridView1.Columns.Count; j++)
                {
                    var Value = Convert.ToString(dataGridView1.Rows[i].Cells[j].Value);
                    if (Value == "Temp01")
                    {
                        dataGridView1.Rows[i].Cells[j].Selected = true; //找到后单元zhi格被dao选中
                    }
                }
            }

5.取消当前的选择

dataGridView1.ClearSelection();//取消当前的选择

6.修改内容

            var Gather = dataGridView1.SelectedCells;
            for (int i=1; i< Gather.Count; i++)
            {
                Gather[i].Value = str[i];
            }

7.选中单行,禁止多选
属性MultiSelect=false

Logo

开源鸿蒙跨平台开发社区汇聚开发者与厂商,共建“一次开发,多端部署”的开源生态,致力于降低跨端开发门槛,推动万物智联创新。

更多推荐