本文介绍了datagridview cell = =“hallo”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
if (dataGridView1.CurrentRow.Cells[0].Value.ToString() == "a")
{
(dataGridView1.CurrentRow.Cells[1] as DataGridViewComboBoxCell).Items.Add("a1"); // populate combobox with items
//dataGridView1.CurrentRow.Cells[2].Value.ToString() == "Hallo"; // Here I try to set the text in cell 3 to Hallo
}
怎么办设置dgv cell [2] =你好?
试试这个
What to do to set dgv cell[2] ="Hallo" ?
Tryed this
private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
{
if (dataGridView1.CurrentCell.Value !=null)
if (dataGridView1.CurrentCell.Value.ToString()=="a")
{
(dataGridView1.CurrentRow.Cells[1] as DataGridViewComboBoxCell).Items.Clear();
(dataGridView1.CurrentRow.Cells[1] as DataGridViewComboBoxCell).Items.Add("a1");
dataGridView1.Rows[0].Cells[2].Value = "Hallo";
}
然后我得到System.ArgumentException:DataGridViewComboBoxCell上的值无效
Then i got System.ArgumentException:Value on DataGridViewComboBoxCell is not valid
推荐答案
dataGridView1.CurrentRow.Cells[2].Value.ToString() == "Hallo";
// Here I try to set the text in cell 3 to Hallo
to
to
datagridview1.CurrentRow.Cells[2].Value = "Hello";
这篇关于datagridview cell = =“hallo”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!