Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


Dataset datagrid and show columns

Posted on 2004-10-28
Medium Priority
Last Modified: 2010-04-24

I have a dataset filled from an access database.
I've binded a datagrid to this dataset.
Several textboxes are binded also to the dataset.
Now I want to show only some of the columns of the dataset in the grid. All the columns are shown in the textboxes?
Do I have to use DataView ? I'm very new to these topics.

Thank you in advance
Question by:kGenius
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
LVL 25

Accepted Solution

RonaldBiemans earned 400 total points
ID: 12433666
Hi Kgenius,

there a a couple of things you can do one is this.

Create your own datagridtablestyle and gridcolumnstyles and just create the ones you want

Dim ts As DataGridTableStyle
        ts = New DataGridTableStyle
        ts.MappingName = ds.Tables(0).ToString()

        Dim col1 As New DataGridTextBoxColumn
        With col1
            .MappingName = "STOCKNUM"
            .HeaderText = "Stock #"
            .Width = 80
        End With

        Dim col2 As New DataGridTextBoxColumn
        With col2
            .MappingName = "DESC"
            .HeaderText = "Description"
            .Width = 100
        End With

        Dim col3 As New DataGridTextBoxColumn
        With col3
            .MappingName = "ASKINGPRICE"
            .HeaderText = "Asking Price"
            .Width = 100
            .Format = "c"
            .TextBox.TextAlign = HorizontalAlignment.Right
            .Alignment = HorizontalAlignment.Right

        End With

        ts.GridColumnStyles.AddRange(New DataGridColumnStyle() {col1, col2, col3})

or set the width of the ones you don't want to 0, like

Dim ts As DataGridTableStyle
        ts = New DataGridTableStyle
        ts.MappingName = ds.Tables(0).ToString()

        DataGrid1.TableStyles(0).GridColumnStyles(0).Width = 100 'show col 1
        DataGrid1.TableStyles(0).GridColumnStyles(1).Width = 0    'don't show col 2 etc..
        DataGrid1.TableStyles(0).GridColumnStyles(2).Width = 100
        DataGrid1.TableStyles(0).GridColumnStyles(3).Width = 0
        DataGrid1.TableStyles(0).GridColumnStyles(4).Width = 100


Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question