简体   繁体   中英

How to add combobox in datagridview in c#?

I want to add combobox column in datagridview in c# by programatically. How can I achieve this? Please help me.

This is one simple approach, which allows to programatically add ComboBox in DataGridView

var combocolumn = new DataGridViewComboBoxColumn();
combocolumn.Name = "Numbers"; // Column name
combocolumn.DataSource = new int[] { "1", "2" }; // Your Data source

dataGridView1.Columns.Add(combocolumn);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM