好了 多说无意,直接上代码,看不看的懂,就看大家的了,解决问题后,可以评论回复,可以一起商讨一些疑难杂症

List<ProtocolInfo> list = piDB.FindAll().ToList(); //都懂吧
for (int i = ; i < list.Count; i++)
{
List<string> tempList = new List<string>(GetDirFiles(list[i].name)).Select(a => Path.GetFileName(a)).ToList(); ///获取 需要显示的集合(可不用理会)
this.Invoke(new MethodInvoker(() =>
{
int index = this.skinDataGridView1.Rows.Add(); //添加新行
this.skinDataGridView1.Rows[index].Cells[].Value = list[i].id; //第一个单元格赋值
this.skinDataGridView1.Rows[index].Cells[].Value = list[i].name; //第二个单元格赋值
this.skinDataGridView1.Rows[index].Cells[].Value = list[i].port; //第三个单元格赋值
this.skinDataGridView1.Rows[index].Cells[].Value = list[i].help; // 第四个单元格赋值
this.skinDataGridView1.Rows[index].Cells[].Value = false; // 第五个 checkbox 复制
for (int ii = ; ii < skinDataGridView1.ColumnCount; ii++)
{
DataGridViewCellStyle dataGridViewCellStyle1 = new DataGridViewCellStyle(); //声明一个 配置项
dataGridViewCellStyle1.NullValue = "需要显示的默认值"; //为空值时需要显示的值 DataGridViewComboBoxCell dgCell = new DataGridViewComboBoxCell();
dgCell.DisplayStyle = DataGridViewComboBoxDisplayStyle.Nothing;
dgCell.Items.AddRange(tempList.Where(a => a.Substring(, ) == (ii - ).ToString()).ToArray()); dgCell.Style = dataGridViewCellStyle1; this.skinDataGridView1.Rows[index].Cells[ii] = dgCell; } }));
}

dataGridView添加ComboBox 每行绑定不同的集合,显示默认值的更多相关文章

  1. DataGridView 添加ComboBox

    http://www.wapsolo.com/Personal/personal_view_75.aspx DataGridView 添加ComboBox 第一: 先在窗体设计时拖一个ComBoBox ...

  2. winform中ComboBox实现text和value,使显示和值分开,重写text和value属性

    winform的ComboBox中只能赋值text,显示和值是一样的,很多时候不能满足根本需要,熟悉B/S开发的coder最常用的就是text和value分开的,而且web下DropDownList本 ...

  3. winform中DataGridView添加ComboBox的最终解决方案(点击ComboBox默认显示当前行的内容)

    第一: 数据绑定ComBoBox控件 先在窗体设计时拖一个ComBoBox控件,然后在里面的ITEMS设好你要下拉项,或者从数据库中的表绑定,这个估计都会. 第二: // 将下拉列表框加入到DataG ...

  4. easyui的combobox将得到的数据设定为下拉框默认值和复选框设定默认值

    通过easyui做了一个表,表里是从数据库拿到的数据. 现在双击某一行,通过点击行的id取到这一行的所有数据,现在需要修改这些得到的数据, 其中部分数据是<select>这个选择的, 问题 ...

  5. EasyUI Combobox 设置默认值

    /** *绑定运营商,设置默认值, 显示CMCC, 传值1 */ $('#operatingId').combobox({ url:'data_url', valueField:'id', textF ...

  6. C#中的ComboBox实现只能选择不能输入,且下拉框中有默认值。

    下拉框有DropDownStyle这一属性,把DropDownStyle类型选为DropDownList,则下拉框只能选择不能输入了.但是这时的下拉框是没有默认值的,即使在Text属性中输入默认值,也 ...

  7. C# DataGridView 动态添加列和行

    https://blog.csdn.net/alisa525/article/details/7350471 dataGridView1.ReadOnly = true ;      //禁用编辑功能 ...

  8. ComboBox控件绑定数据源后,添加'请选择'或'全部'

    ComboBox控件绑定数据源后,添加'请选择'或'全部' 当使用ComboBox控件绑定数据源之后,通过Items 属性添加的数据是无效的,此时如果要在所有选项前添加 选项 ,则需要考虑从数据源下手 ...

  9. C# DataGridView添加新行的2个方法

    可以静态绑定数据源,这样就自动为DataGridView控件添加 相应的行.假如需要动态为DataGridView控件添加新行,方法有很多种,下面简单介绍如何为DataGridView控件动态添加新行 ...

随机推荐

  1. PAT A1016 Phone Bills (25)

    题目描述 A long-distance telephone company charges its customers by the following rules: Making a long-d ...

  2. 树莓派驱动开发 helloworld

    编写Makefile ifneq ($(KERNELRELEASE),) obj-m := MiniX.o else KDIR := /home/hi/pi/kernel/linux/ all: ma ...

  3. ModbusRtu通信报文详解【一】

    Modbus协议可谓是工业控制领域应用最广泛的协议之一.根据不同的电气接口,包括Modbus Rtu/ASCII,Modbus TCP/UDP,从学习的角度来说,只要学会其中一种,剩余的都是大同小异的 ...

  4. [转载]aspnet webapi 跨域请求 405错误

    写了个webapi给同事用ajax调用,配置完跨域以后get请求完全没问题,post就一直报405错误,花了半天时间就是解决不了,后来在网上看到一博主的帖子才知道原来是webapi 默认的web.co ...

  5. PMP - 风险识别之风险登记册

    目录 PMP - 风险识别之风险登记册 1. 风险登记册 1.1 已识别风险的清单 1.2 潜在风险责任人 1.3 潜在风险应对措施清单 2. 相关习题 2.1 风险发生的时候,要实施 风险登记册 上 ...

  6. Tika提取文件元数据

    Tika可以从文件中提取元数据. 什么是元数据: 元数据是文件所提供的的附件信息即文件的属性. word文档的元数据: Tika提取元数据: 我们可以使用文件parse()方法提取元数据,传递一个空的 ...

  7. Plugin 表格列自定义显示隐藏插件TableCustom.js

    TableCustom 案例展示 下载地址 https://github.com/chaorenzeng/TableCustom.js.git 快速使用 1.引入TableCustom.css和Tab ...

  8. 高德地图API-设置考勤范围

    <template> <div class="page-setting-setgps"> <!--head--> <div class=& ...

  9. 【Git的基本操作一】文件初始化及设置签名

    1. 本地库初始化 命令: git init 效果: 

  10. RAD Studio 10.3.2七大新功能介绍

    RAD Studio 10.3.2七大新功能 Delphi支持macOS 64位应用的开发. C++Builder中Windows 64位平台支持C ++ 17特性. C ++ LSP 代码洞察改进. ...