如何使用C#在代码隐藏中添加DataGridTextColumn

时间:2019-12-19 11:08:38

标签: c#

要在DatagridTextColumn中添加Datatable列

//Iterate the Datatable and bind into Datagrid  
      foreach (DataColumn col in tb.Columns)
                    {
                        string colname = col.ColumnName;              

                            GatewayPortsDataGrid.Columns.Add(new DataGridTextColumn
                            {
                                Header = colname,
                                Binding = new Binding(string.Format("[{0}]", colname)),
                            });                                

                    }

0 个答案:

没有答案