DataGrid绑定List<String>

Bound directly DataGrid.ItemsSource = adp is called Length column shows the length of each item;

Requires .Select ( X => new new the Value = {X}) ToList () to display values;

private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            new Thread(() => {
                List<string> adp = MySqlHelper.selectSQL("select name from perinfo;");
                this.Dispatcher.Invoke(DispatcherPriority.Normal, (ThreadStart)delegate {
                    DataGrid.ItemsSource = adp.Select(x => new { Value = x }).ToList();
                });
            }).Start();
        }

Guess you like

Origin www.cnblogs.com/shyw/p/12120689.html