1.添加下拉框

代码实现==》
using System;
using System.Collections.Generic;
using System.Windows.Forms; namespace DgvCombox
{
public partial class Form1 : Form
{
class TextInfo
{
public string MyName { get; set; }
public string Sex { get; set; }
} public Form1()
{
InitializeComponent();
this.dgvList.AutoGenerateColumns = false;
} private void Form1_Load(object sender, EventArgs e)
{
List<string> sexList = new List<string>();
sexList.Add("男");
sexList.Add("女");
List<TextInfo> list = new List<TextInfo>();
list.Add(new TextInfo { MyName = "001", Sex = "男" });
list.Add(new TextInfo { MyName = "002", Sex = "女" });
list.Add(new TextInfo { MyName = "003", Sex = "女" });
list.Add(new TextInfo { MyName = "004", Sex = "女" }); //this.dgvList.DataSource = list; for (int i = 0; i < list.Count; i++)
{
dgvList.Rows.Add();
this.dgvList.Rows[i].Cells[0].Value = list[i].MyName;
this.dgvList.Rows[i].Cells[1].Value = list[i].Sex;
} ((DataGridViewComboBoxColumn)this.dgvList.Columns["Sex"]).DataSource = sexList;
this.dgvList.AllowUserToAddRows = true;
}
}
}

2.按钮列更改背景色

==>

  更改FlatStyle——Flat;

  更改DefaultCellStyle

详细如下图所示:

DateGridView中添加下拉框列并实现数据绑定、更改背景色的更多相关文章

  1. Excel中添加下拉框

    数据->数据验证->数据验证 设置—>允许下拉框中选择序列,来源中写下拉选项,每个选项之间用逗号隔开

  2. table中添加下拉框

    { file: 'usename', title: '下发用户', width:"20%", align: 'center', templet: function (d) { va ...

  3. excel中添加下拉候选

    这里简单记录下如何在Excel2013中添加下拉候选. 首先有个思路是,下拉候选也就意味着数据被限制在一个范围之内,因此应该联想到数据验证相关的设置. 选中单列或单元格,在[数据]下的[数据验证]中选 ...

  4. 选择屏幕中的下拉框和dialog中下拉框设计

    REPORT  YTEST014. PARAMETERS: auart LIKE vapma-auart  AS LISTBOX   VISIBLE LENGTH 6. AT SELECTION-SC ...

  5. 关于GridControl--gridview的下拉框列(下拉列表列)

    1.Run Designer→Columns→需要设置的列→Columns properties→ColumnsEdit→New→选择(repositoryItemComboBox1) 2.给下拉框列 ...

  6. ASP.NET MVC中的cshtml页面中的下拉框的使用

    ASP.NET MVC中的cshtml页面中的下拉框的使用 用上@Html.DropDownList 先记下来..以做备忘...

  7. Revit 命令添加下拉框

    在学习revit制作下拉框时,需要分为三个步骤: 1.创建一个面板(panel). RibbonPanel panel10 = application.CreateRibbonPanel(Global ...

  8. c# dataGridView cell添加下拉框

    应用场景: dataGridView需要某一个cell变成下拉框样式. 思路详解: dataGridVie添加固定格式的row. 代码: DataGridViewRow row = new DataG ...

  9. vue中使用cookie记住用户上次选择(本次例子中为下拉框)

    最近工作中碰到一个需求,添加一条数据时,自动记住上次选择的下拉框的数据,刚开始觉得没思路,后来请教了项目组长,组长直接一句,这不很简单吧,直接用cookie,我:....... 好吧,都王的差不多了, ...

随机推荐

  1. (实用篇)php精确的统计在线人数的方法

    这是一个非常精确的,通过php实现统计在线人数的方法,想知道怎么实现的请耐心阅读. <?php $filename='online.txt';//数据文件 $cookiename='VGOTCN ...

  2. 去掉hint提示文字

    想要去掉EditText的hint提示文字,首先需要给EditText的父控件加上如下两个属性,使其获得焦点: android:focusable="true" android:f ...

  3. Validform:一行代码搞定整站的表单验证!

    表单验证不再发愁,http://validform.rjboy.cn/

  4. lable自动适配大小

    #import "ViewController.h" @interface ViewController () @end @implementation ViewControlle ...

  5. 《C标准库》—之<assert.h>实现

    首先,贴出标准库中<assert.h>的实现源码: #undef assert #ifdef NDEBUG #define assert(test)((void)0) #else void ...

  6. Oracle 删除用户和表空间

    版权声明:本文为博主原创文章,未经博主允许不得转载. Oracle 使用时间长了, 新增了许多user 和tablespace. 需要清理一下 对于单个user和tablespace 来说, 可以使用 ...

  7. leetcode 101 Symmetric Tree ----- java

    Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center). For e ...

  8. linux服务之vnc和x2go

    三种方式连接linux桌面 1.传统的vnc linux桌面上安装vncserver windows桌面上安装vncviewer 2.x2go 在linux桌面上安装x2goserver与x2gose ...

  9. mov视频转gif

    在mac上用quicktime录屏,得到一个mov视频,想转成gif,试了几个工具,感觉下面这个最好用: http://ezgif.com/video-to-gif 支持重新指定尺寸和帧率,转完gif ...

  10. 题目1049:字符串去特定字符——九度OJ

    题目1049:字符串去特定字符 http://ac.jobdu.com/problem.php?pid=1049 时间限制:1 秒 内存限制:32 兆 题目描述: 输入字符串s和字符c,要求去掉s中所 ...