Spread 8.0 Documentation
Example
Support Options

Glossary Item Box

Example


The following example creates a sheet with multiple column headers. The top row of headers spans column in the second and third row of headers, as shown in the following figure. The user sort indicator is displayed in the second row of headers. The sheet does not display the row headers.

C++

void CmyWnd::MyFunc()
{
    // Set number of columns and rows
    m_Spread1.SetMaxCols(6);
    m_Spread1.SetMaxRows(250);
    // Turn off display of row headers
    m_Spread1.SetRowHeadersShow(FALSE);
    // Set up column headers
    m_Spread1.SetColHeaderRows(3);
    m_Spread1.AddCellSpan(1, SPREADHEADER, 3, 1);
    m_Spread1.AddCellSpan(4, SPREADHEADER, 3, 1);
    m_Spread1.SetRow(SPREADHEADER);
    m_Spread1.SetCol(1);
    m_Spread1.SetText("National Parks");
    m_Spread1.SetCol(4);
    m_Spread1.SetText("State Parks");
    m_Spread1.SetRow(SPREADHEADER + 1);
    m_Spread1.SetCol(1);
    m_Spread1.SetText("Name");
    m_Spread1.SetCol(2);
    m_Spread1.SetText("State");
    m_Spread1.SetCol(3);
    m_Spread1.SetText("Size (Acres)");
    m_Spread1.SetCol(4);
    m_Spread1.SetText("Name");
    m_Spread1.SetCol(5);
    m_Spread1.SetText("State");
    m_Spread1.SetCol(6);
    m_Spread1.SetText("Size (Acres)");
    // Display sorting indicator in lowest header row for
    // Name columns
    m_Spread1.SetUserColAction(1);
    m_Spread1.SetColUserSortIndicator(2, 2);
    m_Spread1.SetColHeadersUserSortIndex(1);
}

Visual Basic

Private Sub Form_Load()
    ' Set number of columns and rows
    fpSpread1.MaxCols = 6
    fpSpread1.MaxRows = 250
    ' Turn off display of row headers
    fpSpread1.RowHeadersShow = False
    ' Set up column headers
    fpSpread1.ColHeaderRows = 3
    fpSpread1.AddCellSpan 1, SpreadHeader, 3, 1
    fpSpread1.AddCellSpan 4, SpreadHeader, 3, 1
    fpSpread1.Col = 1
    fpSpread1.Row = SpreadHeader
    fpSpread1.Text = "National Parks"
    fpSpread1.Col = 4
    fpSpread1.Row = SpreadHeader
    fpSpread1.Text = "State Parks"
    fpSpread1.Col = 1
    fpSpread1.Row = SpreadHeader + 1
    fpSpread1.Text = "Name"
    fpSpread1.Col = 2
    fpSpread1.Row = SpreadHeader + 1
    fpSpread1.Text = "State"
    fpSpread1.Col = 3
    fpSpread1.Row = SpreadHeader + 1
    fpSpread1.Text = "Size (Acres)"
    fpSpread1.Col = 4
    fpSpread1.Row = SpreadHeader + 1
    fpSpread1.Text = "Name"
    fpSpread1.Col = 5
    fpSpread1.Row = SpreadHeader + 1
    fpSpread1.Text = "State"
    fpSpread1.Col = 6
    fpSpread1.Row = SpreadHeader + 1
    fpSpread1.Text = "Size (Acres)"
    ' Display sorting indicator in lowest header row for
    ' Name columns
    fpSpread1.UserColAction = UserColActionSort
    fpSpread1.ColUserSortIndicator(2) = ColUserSortIndicatorDescending
    fpSpread1.ColHeadersUserSortIndex = 1
End Sub

© 2002-2014 ComponentOne, a division of GrapeCity. All Rights Reserved.