Home Forums WinForms controls Xceed Grid for WinForms DetailGridTemplate

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #16388 |

    Can I use the DetailGridTemplate to dictate which columns from a  data source to display?

    For example.  I have a dataset that has the following columns.
    FirstName
    LastName
    Address
    City
    State
    Zip

    If I only want FirstName and LastName to show in the detail grid could I then do something like this?

    Dim detail As New Xceed.Grid.DetailGrid()

    Dim FirstNameColumn As New Xceed.Grid.Column(“FirstName”, GetType(System.String))
    detail.Columns.Add(FirstNameColumn)

    Dim LastNameColumn As New Xceed.Grid.Column(“LastName”, GetType(System.String))
    detail.Columns.Add(LastNameColumn)

    detail.DataSource = Nothing
    detail.DataMember = “ContactDetails”

    xBigContactGrid.DetailGridTemplates.Add(detail)
     

    If the datamember contains all the columns will the detail now only show the two that I added?

     

    Brian

    Imported from legacy forums. Posted by Brian (had 721 views)

    User (Old forums)
    Member
    Post count: 23064

    You have two choices.

    You can simply hide the columns you don’t want.

    e.g.:  gridControl1.Columns( “Address” ).Visible = false;

    Or you can turn off the auto generating of columns when the grid is bound, and provide only the ones you want.

    e.g.:

    detail.AutoCreateColumns = false;

    Dim FirstNameColumn As New DataBoundColumn( “FirstName” )

    detail.Columns.Add( FirstNameColumn )

    Then bind the grid.

     

    Imported from legacy forums. Posted by André (had 231 views)

    User (Old forums)
    Member
    Post count: 23064

    Thanks, the second method is what I ended up with.  I was handlig the Initialize detail grid event as well but found it to be to slow to process all the detail grids at once.  Instead I am now using the colapsechange event and dealing with them when they are shown, this works well since they may or may not expand them all.

    For each of the detail grids I simply create the databound column for only what I want shown, set the properties once(instead of each time as in using the initialize event) and save it as the template.

     

    The template concept was new to me comming from teh MS grid but now it is starting to make more sense. Creating the columns and setting the properties for teh template is much faster tahn doint it for each detail grid in teh initalize event.

     

    Thanks for the reply.

    Imported from legacy forums. Posted by Brian (had 994 views)

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.