Results 1 to 3 of 3

Thread: datagrid - hide columns

  1. #1

    Thread Starter
    Member
    Join Date
    Nov 2002
    Location
    Austria
    Posts
    52

    datagrid - hide columns

    hi!

    Is it possible to hide one ore more columns of a datagrid?

    I have a dataset which contains all fields of a sql-server-table but i only want to show a few of them.

    Of course i could create a dataset which contains only the necessary fields but in this case i have to read the data from the sql-server once again.

    thanks
    Robert

  2. #2
    Addicted Member CoMMiE's Avatar
    Join Date
    Jul 2000
    Location
    Malaysia, Kuala Lumpur
    Posts
    179
    Yes you can
    just set the datagridtextboxcolumn.width properties of the mapping column to zero

  3. #3

    Thread Starter
    Member
    Join Date
    Nov 2002
    Location
    Austria
    Posts
    52
    thanks...

    here's my coding... the method objBenutzer.getAllBenutzer() generates a dataset with 15 fields but only the 3 mapped fields are shown in the datagrid.


    Dim objBenutzer As New cls_ety_benutzer()
    objBenutzer.getAllBenutzer()

    Dim dgTableStyle = New DataGridTableStyle()
    Dim dgTextBoxColumn1 = New DataGridTextBoxColumn()
    Dim dgTextBoxColumn2 = New DataGridTextBoxColumn()
    Dim dgTextBoxColumn3 = New DataGridTextBoxColumn()

    dgTableStyle.DataGrid = Me.dgBenutzer
    dgTableStyle.GridColumnStyles.AddRange(New DataGridColumnStyle() {dgTextBoxColumn1, dgTextBoxColumn2, dgTextBoxColumn3})
    dgTableStyle.HeaderForeColor = System.Drawing.SystemColors.ControlText
    dgTableStyle.MappingName = "tbl_cu_benutzer"
    dgTableStyle.ReadOnly = True

    dgTextBoxColumn1.Format = ""
    dgTextBoxColumn1.FormatInfo = Nothing
    dgTextBoxColumn1.MappingName = "Benutzername"
    dgTextBoxColumn1.Width = 75

    dgTextBoxColumn2.Format = ""
    dgTextBoxColumn2.FormatInfo = Nothing
    dgTextBoxColumn2.MappingName = "Vorname"
    dgTextBoxColumn2.Width = 75

    dgTextBoxColumn3.Format = ""
    dgTextBoxColumn3.FormatInfo = Nothing
    dgTextBoxColumn3.MappingName = "Nachname"
    dgTextBoxColumn3.Width = 75

    ' Tablestyle dem Datagrid zuweisen
    dgBenutzer.TableStyles.Add(dgTableStyle)

    dgBenutzer.SetDataBinding(objBenutzer.DataSet, "tbl_cu_benutzer")

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width