1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Column visibility and sequence wpf datagrid

Discussion in 'Programming' started by lifeguru02, May 16, 2016.

  1. lifeguru02

    lifeguru02 New Member

    Joined:
    May 12, 2016
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    which is the best way I can do column visibility and sequence to my grid. I am using dapfor wpf gridcontrol.
     
  2. alexandarx5

    alexandarx5 New Member

    Joined:
    May 12, 2016
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    A programmer may also set column visibility and position. To define a manage visibility columns have Column.Visible property. Column visibility covers only the column panel. It is also possible to group data by hidden columns. Moreover, columns that are used for grouping are usually not displayed. An example of managing column visibility via API is shown below:
    C#
    Code:
    Header header = new Header(); 
    header.Columns.Add(new Column("Column1")); 
    header.Columns.Add(new Column("Column2")); 
    
    Debug.Assert(header[0].Id == "Column1"); 
    Debug.Assert(header[1].Id == "Column2"); 
    Debug.Assert(header.VisibleColumns[0].Id == "Column1"); 
    Debug.Assert(header.VisibleColumns[1].Id == "Column2"); 
    Debug.Assert(header["Column1"].VisibleIndex == 0); 
    Debug.Assert(header["Column2"].VisibleIndex == 1); 
    
    //Hide the first column 
    header["Column1"].Visible = false; 
    
    //The header has the single visible column 
    Debug.Assert(header.VisibleColumns.Count == 1); 
    Debug.Assert(header.VisibleColumns[0].Id == "Column2"); 
    Debug.Assert(header["Column2"].VisibleIndex == 0); 
    
    //Enumerate all visible columns 
    foreach (Column column in header.VisibleColumns) 
    { 
        //Some code here... 
    } 
    
    //Hide all columns 
    header.VisibleColumns.Clear();
     

Share This Page