datagridview里的一个列,我设置成了下拉框,然后下拉框也有数据填充进去了,但是有个问题,我每次在打开窗体的时候,下拉框是空的,你点上去,下拉框是有值的
  我想知道如何让下拉框在第一次打开窗体的时候能出来值

解决方案 »

  1.   

    在Load事件中设置:
    datagridview[row, column].value = defaultvalue;
      

  2.   

            DataGridViewComboBoxCell c;
            c.Value = c.Items[2].ToString();
      

  3.   

    dataGridView1.CurrentRow.Cells[1].Value
    string selectValue =(string)(this.dataGridView1.Rows[e.RowIndex].Cells[1] as DataGridViewComboBoxCell).Value; 
      

  4.   

    WinForm都忘得差不多了。Asp.net里面是这样写的:
    DropDownList ddl = vUnitOnline.SelectedIndex].Cells[0] as DropDownList)
    ddl.
    但你要选中哪个的话就要遍历了
    for(int i = 0;i<ddl.items.count;i++)
    {
        //这个地方不一定判断selectedValue,还可以用selectedText或selectedIndex
        if(ddl.items[i].selectedvalue == "你要显示的值") 
        {
             ddl.items[i].selected = true;
        }
    }
      

  5.   

     datagridview 右上角小三角 (智能标记)——》 编辑列 (选择下拉的那一列)——》 DefaultCellStyle ————》数据(NullValue) 填默认值