Reputation: 183
I am working on vb.net windows application..i am populating my data grid view using data source..I wrote code in my load event like this:
Dim cd As SqlCommandBuilder = New SqlCommandBuilder(adapter)
adapter = New SqlDataAdapter("select c.cid,c.CompanyName,d.dtId,d.dtName as
Department,d.dtPhone as Phone,d.dtEmail as Email,d.empimage from CompanyMaster_tbl c
join DepartmentMaster_tbl d on c.Cid=d.cId order by cid", con.connect)
dt1 = New DataTable
bSource = New BindingSource
adapter.Fill(dt1) 'Filling dt with the information from the DB
bSource.DataSource = dt1
gv.DataSource = bSource
gv.Columns("cid").Visible = False
gv.Columns("dtId").Visible = False
Dim img As New DataGridViewImageColumn
img.HeaderText = "image"
gv.Columns.Insert(6, img)
now my gridview showing like this:
i want to show my image in my **image**
column it self..how i can do that?
Upvotes: 0
Views: 1885
Reputation: 6079
After assigning the datasource your adding the column "gv.Columns.Insert(6, img)". For this column data is not there. You need to add the images manually to this column.
for(int i = 0; i < gv.Rows.Count; i++)
{
gv.Rows[i]["image"] = gv.Rows[i]["empimage"];
}
Upvotes: 1