datagridview、combobox相关代码属性

设置datagridview中,某行被选中并且移动到选中行的位置

dataGridView6.Rows[选中的行号].Selected = true;//设置某行被选中
dataGridView6.CurrentCell = dataGridView6.Rows[选中的行号].Cells[0];//移动到选中的行

清除combobox中text的内容,保留下拉列表中的内容

comboBox2.Text = "";//清除text内容,保留下拉菜单内容

获取combobox中选中数据的行号

int i = int.Parse(comboBox2.SelectedIndex.ToString());

 向datagridview中写入数据,改变单元格中字体颜色 

dataGridView4.Rows[i].Cells[1].Value=要写入的数据
dataGridView4.Rows[行号].Cells[列号].Style.ForeColor = Color.颜色;
posted @ 2021-01-20 15:24  沉迷代码不能自拔  阅读(99)  评论(0编辑  收藏  举报