查MSDN关键字DataGridColumnStyle,里面有DataGrid列写的内容,包括示例,好像就是ComboBox的
解决方案 »
- EF框架查询提示,值不在预期的范围内
- 谁会使用scintillaNET控件?
- 怎样检查能否链接到某网站?
- 我读取XML的时候用XmlDocument对象加载XML 运行时候报错 错误是根级别上的数据无效. 行 1,位置 41.
- 关于身份证的验证。。。。。。。
- 第一个程序
- 求助,关于获取解析网易云音乐网页源码问题,脚本加载完后的....
- 老板 叫做个管理程序 --要求提示每天要干什么工作的。。 各位大虾谁有做过现成的吗 非常感谢 最好是c#做的 别带数据库的(老板不会用)
- System.NullReferenceException: 未将对象引用设置到对象的实例(datagrid中dropdownlist的绑定问题)
- 为什么我的C#的WEB项目打不开,新手上路
- dataGrid1可编缉问题 (急)
- 使用OLE DB和ADO访问oracle 返回记录集的存储过程
http://blog.csdn.net/tjvictor/archive/2007/01/22/1489807.aspx
private void FillGrid()
{
DataGridViewRow dgr = null;
ArrayList blockArr = (ArrayList)this.Tag; int count = blockArr.Count;
int i = 0; string first=""; dataGridView1.RowCount = count;
try
{
foreach (InPutBlock block in blockArr)
{
first = block.ParentDocument.FileName;
dgr=dataGridView1.Rows[i];
FillRow(first, ref dgr, block);
i++;
} }
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
} private void FillRow(string firstCol, ref DataGridViewRow dgr, InPutBlock inputBlock)
{
try
{
dgr.Cells[0].Value = firstCol;
dgr.Cells[1].Value = inputBlock.ValName;
dgr.Cells[2].Value = inputBlock.GetTabName();
//dgr.Cells[2].Tag = inputBlock.InType; //将输入端子类型附加到第二个单元格tag上
FillCommbox(inputBlock.InType);
DataGridViewComboBoxCell comCell = (DataGridViewComboBoxCell)dgr.Cells[3];
comCell.Items.AddRange(nameArr.ToArray());
if(inputBlock.PinName!="")
dgr.Cells[3].Value = inputBlock.PinName; //dataGridView1.Rows.Add(dgr);
dgr.Tag = inputBlock; //为保存做准备,一行对应一个定值参数
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
} private void FillCommbox(InputType type)
{
XmlFile xmlFile = new XmlFile(strResDir); switch (type)
{
case InputType.AI:
xmlFile.LoadXml(strResDir + "\\AI.xml");
break;
case InputType.DI:
xmlFile.LoadXml(strResDir + "\\DI.xml");
break;
case InputType.FI:
xmlFile.LoadXml(strResDir + "\\Frequency.xml");
break;
case InputType.MI:
xmlFile.LoadTotalMeasure();
break;
case InputType.YI:
xmlFile.LoadXml(strResDir + "\\Pressboard.xml");
break;
} nameArr =xmlFile.NameArr;
indexArr = xmlFile.IndexArr; }