首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

为什么这段代码运行出来连列都没有呈现出来

2013-02-24 
为何这段代码运行出来连列都没有呈现出来目的很简单,.就是在DataGridView3加载完数据以后,在右边加入一列

为何这段代码运行出来连列都没有呈现出来
目的很简单,.
就是在
DataGridView3加载完数据以后,在右边加入一列来专门显示图片.图片路径好处理.
但是这个列按照下面代码运行没加上.不知道什么问题.求指教.
DataGridView第一次用.

           
cmd.CommandText = sql;//sql语句    
            SqlDataReader dr = cmd.ExecuteReader(); 
            BindingSource bs = new BindingSource();
            bs.DataSource = dr;
            this.dataGridView3.DataSource = bs;
            DataGridViewImageColumn column = new DataGridViewImageColumn();
            dataGridView3.Columns.Add(column);
            column.HeaderText = "图片";
            DataGridView3["Image", 0].Value = new Bitmap("图片路径");
            



[解决办法]
column.Width=100;
column.Visible=true;
...
[解决办法]
你得在DataTable里增加这一列。datasource绑定后。不能更改列了。。

热点排行