如何在绑定后以编程方式更改datagridview列类型

时间:2016-11-14 11:49:07

标签: c# datagridview column-types

我将字符串数据源列表绑定到gridview,然后我尝试将它们更改为DataGridViewLinkCell,但它没有反映在gridview上。

public ExpandReport(String operation,List<string> dataSource,string companyCode,string DBName, string DType)
        {
            try
            {
                InitializeComponent();
                this.ex_dataGridView.DefaultCellStyle.Font=new Font("Verdana", 8);
                ex_linkLabel.Text = operation;
                filteredResult = dataSource;
                ex_dataGridView.DataSource = dataSource.ConvertAll(x => new { Value = x });
                company_Code = companyCode;
                DB_Name = DBName;
                D_Type = DType;

                if (DType.Equals("QT"))
                {
                    foreach (DataGridViewRow row in ex_dataGridView.Rows)
                    {
                        DataGridViewLinkCell linkCell = new DataGridViewLinkCell();
                        linkCell.Value = row.Cells[0].Value;
                        row.Cells[0] = linkCell;
                    }
                }
            }

0 个答案:

没有答案
相关问题