Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public partial class Form4 : Form
- {
- private BindingList<test1> bl = new BindingList<test1>();
- public static test2[] values = { new test2("none"), new test2("one"), new test2("two") };
- public Form4()
- {
- InitializeComponent();
- //bl.Add(new test1());
- dataGridView1.AutoGenerateColumns = false;
- dataGridView1.AutoSize = true;
- dataGridView1.DataSource = bl;
- dataGridView1.Columns.AddRange(getColumn());
- }
- private DataGridViewColumn getColumn()
- {
- var combo = new DataGridViewComboBoxColumn();
- combo.DataSource = values;
- combo.DataPropertyName = "t2";
- combo.DisplayMember = "s";
- combo.ValueMember = "Value";
- return combo;
- }
- }
- public class test1
- {
- private test2 _t2;
- public test2 t2
- {
- get
- {
- return _t2;
- }
- set
- {
- _t2 = value;
- }
- }
- public test1(test2 t2)
- {
- this.t2 = t2;
- }
- public test1()
- {
- }
- }
- public class test2
- {
- public string s { get; set; }
- public test2 Value {
- get { return this; }
- }
- public test2(string s = "none")
- {
- this.s = s;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement