locked
Hiding the changes (entity state) column in datagrid or list RRS feed

  • Question

  • I would like to hide the changes (entity state) column in a data grid or list.

    I am currently performing automatic changes on rows in the grid and it can be confusing to the user to see the asterisk.  I would like to hide this column for some specific datagrids / lists.

    I'm aware that one can use FindControl on the datagrid/list to hide regular data columns, but I have not been able to find how to hide this specific column.

    Thanks in advance!

    Monday, December 3, 2012 3:37 PM

Answers

  • FIrst, you'll need to import a reference to System.Windows.Controls (at the top of the screen's code file), if you don't already have one.

    Imports System.Windows.Controls

    In the screen's Created method, you need to add a ControlAvailable handler. Replace "ScreensName" with the actual name of your screen, & "DataGridsName" with the actual name of the data grid.

    Private Sub ScreensName_Created()
        AddHandler Me.FindControl("DataGridsName").ControlAvailable, AddressOf DataGrid_ControlAvailable
    End Sub

    Then in the handler, you need to cast e.Control to a DataGrid. You can then set the data grid's HeadersVisibility property to Column, which only shows the column headers, & not the row headers.

    Private Sub DataGrid_ControlAvailable(sender As Object, e As ControlAvailableEventArgs)
        Dim grid = TryCast(e.Control, DataGrid)
        If (grid Is Nothing) Then Return
    
        grid.HeadersVisibility = DataGridHeadersVisibility.Column
    End Sub
    It's a couple of steps, but it's pretty easy once you know how. Of course other DataGrid properties can also be set in this way too.

    Yann - LightSwitch Central - Click here for FREE Themes, Controls, Types and Commands
     
    Please click "Mark as Answer" if a reply answers your question. Please click "Vote as Helpful" , if you find a reply helpful.
     
    By doing this you'll help others to find answers faster.

    • Marked as answer by Winney Tuesday, December 4, 2012 7:18 PM
    Tuesday, December 4, 2012 1:08 AM
    Moderator

All replies

  • FIrst, you'll need to import a reference to System.Windows.Controls (at the top of the screen's code file), if you don't already have one.

    Imports System.Windows.Controls

    In the screen's Created method, you need to add a ControlAvailable handler. Replace "ScreensName" with the actual name of your screen, & "DataGridsName" with the actual name of the data grid.

    Private Sub ScreensName_Created()
        AddHandler Me.FindControl("DataGridsName").ControlAvailable, AddressOf DataGrid_ControlAvailable
    End Sub

    Then in the handler, you need to cast e.Control to a DataGrid. You can then set the data grid's HeadersVisibility property to Column, which only shows the column headers, & not the row headers.

    Private Sub DataGrid_ControlAvailable(sender As Object, e As ControlAvailableEventArgs)
        Dim grid = TryCast(e.Control, DataGrid)
        If (grid Is Nothing) Then Return
    
        grid.HeadersVisibility = DataGridHeadersVisibility.Column
    End Sub
    It's a couple of steps, but it's pretty easy once you know how. Of course other DataGrid properties can also be set in this way too.

    Yann - LightSwitch Central - Click here for FREE Themes, Controls, Types and Commands
     
    Please click "Mark as Answer" if a reply answers your question. Please click "Vote as Helpful" , if you find a reply helpful.
     
    By doing this you'll help others to find answers faster.

    • Marked as answer by Winney Tuesday, December 4, 2012 7:18 PM
    Tuesday, December 4, 2012 1:08 AM
    Moderator
  • Thanks Yann!!  It worked!
    Tuesday, December 4, 2012 7:19 PM
  • You're welcome Winney!

    (Of course it worked, LOL) :-)


    Yann - LightSwitch Central - Click here for FREE Themes, Controls, Types and Commands
     
    Please click "Mark as Answer" if a reply answers your question. Please click "Vote as Helpful" , if you find a reply helpful.
     
    By doing this you'll help others to find answers faster.

    Wednesday, December 5, 2012 5:44 AM
    Moderator