YYkun
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

详细如下图所示:

 

分类:

技术点:

相关文章:

  • 2021-03-30
  • 2021-07-30
  • 2021-09-23
  • 2022-01-24
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-12-19
  • 2021-11-02
  • 2021-06-04
相关资源
相似解决方案