0

如何将 DataGridView 绑定到双精度列表?

我所做的是:

    private List<double> x_axis_values = new List<double>();

    public main()
    {
        InitializeComponent();
        var source = new BindingSource();
        source.DataSource = this.x_axis_values;
        this.dataGridViewX.DataSource = source;
    }

但是当我更新列表时,DataGridView 仍然为空。抱歉,使用 DataGridView 的第一天...

4

1 回答 1

0
private List<double> x_axis_values = new List<double>();
private BindingSource bindingSource = new BindingSource();;
    public main()
    {
        InitializeComponent();   
        bindingSource.DataSource =  this.x_axis_values.Select(x => new { Value = x }).ToList();
        dataGridViewX.DataSource = bindingSource;        
    }
于 2013-04-19T18:46:42.883 回答