从DataGridViewComboBoxColumn选择价值

从DataGridViewComboBoxColumn选择价值

本文介绍了从DataGridViewComboBoxColumn选择价值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何选择DataGridViewComboBoxColumn值作为默认?在DataGrid中有4列以及一个DataGridViewComboBoxColumn。数据tabale被绑定的网格但DataGridViewComboBoxColumn我已经设置值项目集合中的设计模式。

I am wondering how to select a DataGridViewComboBoxColumn value as a default? In DataGrid there are 4 columns along with a DataGridViewComboBoxColumn. A data tabale is binding the grid but for DataGridViewComboBoxColumn I have set values as items collection in design mode.

能否请你帮我怎样才能从DataGridViewComboBoxColumn作为默认选择第一项?目前,它显示了点击下拉的所有项目下来,但作为缺省或第一个项目它显示为空。

Can you please help how I can select first item from DataGridViewComboBoxColumn as default ? Currently it shows all items on clicking drop down but as a default or first item it shows empty.

推荐答案

NullValue属性的作品,但它有一些问题,例如,选择其它值之后。我不'吨删除它...所以我用:

the NullValue works, but it has some problems, for example, after selecting other value, i couldn't erase it...so i used:

private void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
  {
     if (e.ColumnIndex == 0) // your combo column index
     {

        e.Value = "Dr.";

     }
  }

这篇关于从DataGridViewComboBoxColumn选择价值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-29 23:58