如何从数据集填充datagridviewtextboxcolumn [英] How to fill datagridviewtextboxcolumn from dataset

查看:241
本文介绍了如何从数据集填充datagridviewtextboxcolumn的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有datagridview,其中包含总共14列,其中前9列是从一个表(datafile)填充的,另外5列是我以编程方式添加的,如下所示。



I have datagridview which contains total 14 columns out of which first 9 columns are filled from one table("datafile") and other 5 columns i have added programatically as shown below.

Dim col_Prof As New DataGridViewTextBoxColumn()
            With col_Prof
                .Name = "xx"
                .HeaderText = "xx"
                .ReadOnly = False
            End With
            dgvUserDetails.Columns.Add(col_Prof)





现在我希望从另一个表(Prof)中填充此列d绑定到grid.Is有可能吗?如果是的话怎么样?



Now I want this column to be filled from another table("Prof") and bind to grid.Is it possible to do so?if yes how?

推荐答案

这样......

this way...
Dim col_Prof As New DataGridViewTextBoxColumn()
With col_Prof
    .Name = "xx"
    .HeaderText = "xx"
    .ReadOnly = False
    .DataPropertyName = "Column1"  ' here name of column from datatable
End With
dgvUserDetails.Columns.Add(col_Prof)

dgvUserDetails.AutogenerateColumns = false
dgvUserDetails.Datasource = Ds.Tables(0)



快乐编码!

:)


Happy Coding!
:)


这篇关于如何从数据集填充datagridviewtextboxcolumn的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆