ListView vs. ListBox for multiple column usage

前端 未结 4 1142
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-02 13:11

I am currently struggling with the GUI of my application. I have a hard time figuring out whether the ListBox or ListView is more \"suitable\" for multi-column representation of

4条回答
  •  孤独总比滥情好
    2021-02-02 13:35

    There's certainly nothing wrong with a DataGridView in this scenario.

    Sample:

    class Car
    {
        public string Make { get; set; }
        public string Model { get; set; }
        public int Year { get; set; }
    }
    

    A function to load the data to the DataGridView

    private void LoadData()
    {
        List cars = new List()
        {
           new Car() { Make = "Subaru", Model = "Impreza", Year = 2005 },
           new Car() { Make = "Ford", Model = "Mustang", Year = 1984 }
        };
    
        dataGridView1.DataSource = cars;
    }
    

    Of course, from here things can get more complicated, but if you simply want to display data in a tabular fashion... it's pretty simple.

提交回复
热议问题