datagridview cell = =“hallo” [英] datagridview cell to be ="hallo"

查看:61
本文介绍了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

推荐答案

尝试更改此



Try changing this

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


试试这个

datagridview1.Rows [currentrowindex] .Cells [2] .Text =你好





如果是在windows中试试它

datagridview1.Rows [currentrowindex] .Cells [2] .value =hello
try this
datagridview1.Rows[currentrowindex].Cells[2].Text="hello"


if it is in windows try it as
datagridview1.Rows[currentrowindex].Cells[2].value="hello"


这篇关于datagridview cell = =“hallo”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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