如何在表格的表格中显示某些列? [英] How to show some columns in table in Grid?

查看:95
本文介绍了如何在表格的表格中显示某些列?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好所有访客
我在vb.net中遇到了网格问题.
我有一个数据源并链接到我的表.
当我将该数据源放到窗体中时,它将在窗体上显示一个网格.
问题在于我表中的所有字段都将显示在网格"列上.
EX:表中有8个列,因此在Grid中也将显示8个列.
实际上,我只想在网格上显示一些列.

最好的问候.

Hi all visitors
I have problem with Grid in vb.net.
I have a datasource and link to my table.
when i drop down that datasource to my form, it will show a Grid on my form.
The problem is that all fields in my table will show on the Grid columns.
EX: in table has 8 cols, so in Grid will show 8 cols too.
In fact i just want to show some cols on my grid only.

Best Regards.

推荐答案

看看这个: ^ ]

您可以根据需要定义和映射列.

如果您需要更多的知识和学习,则只用Google.
Have a look at this: How to set up DataGrid Columns programatically[^]

You can define and map the columns as per your need.

Just Google for it, if you need more to know and learn.


您可以尝试一下...
You can play around with this...
Private Sub FormatDataGridX(dgv as DataGridView)

  For i As Integer = 0 To dgv.Columns.Count - 1
    
    Select Case dgv.Columns(i).HeaderText
      
      Case "Id"
        dgv.Columns(i).Visible = False
      Case "Comments"
        dgv.Columns(i).Visible = False
      Case "...."
        ....

    End Select

  Next ' i

End Sub


这篇关于如何在表格的表格中显示某些列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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