SPView.GroupByHeader Property

Gets or sets the definition of the Group By header used in the view.

Namespace:  Microsoft.SharePoint
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: Yes
Available in SharePoint Online

'Declaration
Public Property GroupByHeader As String
	Get
	Set
'Usage
Dim instance As SPView
Dim value As String

value = instance.GroupByHeader

instance.GroupByHeader = value

Property Value

Type: System.String
A Collaborative Application Markup Language (CAML) string that contains the header definition.

If you set values through the GroupByHeader property, you must use the Update method for changes to take effect in the database.

The following code example uses the GroupByHeader property to customize the font size, font color, and background color of the Group By header area in a view within a specified site of the current site collection.

Dim siteColl As SPSite = SPControl.GetContextSite(Context)
Dim site As SPWeb = siteColl.AllWebs("Site_Name")
Dim list As SPList = site.Lists("List_Name")
Dim view As SPView = list.Views("View_Name")

view.GroupByHeader = "<HTML><![CDATA[<TBODY id='titl]]></HTML>" _
    & "<GetVar Name='GroupByLevelString' />" _
    & "<HTML><![CDATA['><TR STYLE='font-size:14pt;color:red']]></HTML>" 
        _
    & "<Switch><Expr><GetVar Name='GroupByIndent' /></Expr>
        <Case Value='0'>" _
    & "<HTML><![CDATA[ class='ms-gb' ]]></HTML></Case><Default>" _
    & "<HTML><![CDATA[ class='ms-gb2' ]]></HTML></Default></Switch>" _
    & "<HTML><![CDATA[><TD colspan='100' nowrap BGCOLOR='white'>" _
    & "<img src='/_layouts/images/blank.gif' alt='' height=1 width=]]>" 
        _
    & "</HTML><GetVar Name='GroupByIndent' />" _
    & "<HTML><![CDATA[><a href='javascript:' 
        onclick='javascript:ExpCollGroup(']]></HTML>" _
    & "<GetVar Name='GroupByLevelString' />
        <HTML><![CDATA[','img_]]></HTML>" _
    & "<GetVar Name='GroupByLevelString' />
        <HTML><![CDATA[');return false;'><img id='img_]]></HTML>" _
    & "<GetVar Name='GroupByLevelString' />
        <HTML><![CDATA[' src='/_layouts/images/minus.gif' 
        alt=']]></HTML>" _
    & "<HTML>Expand/Collapse</HTML>
        <HTML><![CDATA[' border='0'></a>&amp;nbsp;]]></HTML>" _
    & "<GetVar Name='GroupByField' HTMLEncode='TRUE' />
        <HTML><![CDATA[ :&amp;nbsp;]]></HTML>" _
    & "<GetVar Name='GroupByValue' />
        <HTML><![CDATA[</TD></TR></TBODY>]]></HTML>" _
    & "<HTML><![CDATA[<TBODY id='tbod]]></HTML>
        <GetVar Name='GroupByLevelString' HTMLEncode='TRUE' />" _
    & "<HTML><![CDATA[_'>]]></HTML><SetVar Name='EvenRow' 
        Scope='Request' Value='0' />" _
    & "<SetVar Name='OnlyOneItem' Scope='Request' Value='1' />"

view.Update() 
NoteNote

Certain objects implement the IDisposable interface, and you must avoid retaining these objects in memory after they are no longer needed. For information about good coding practices, see Disposing Objects.

Show: