Creating a Non-Scrollable Row
To fix a row in the grid so that it will not scroll, complete the following steps:
1. Add the following code to the Page_Load event to allow scrolling and fixed rows:
' Set the grid's height and width.
C1GridView1.Height = 250
C1GridView1.Width = 450
' Turn scrolling on.
C1GridView1.ScrollSettings.ScrollMode = C1.Web.UI.Controls.C1GridViewScrollMode.ScrollBar
' Set both horizontal and vertical scrolling.
C1GridView1.ScrollSettings.ScrollOrientation = C1.Web.UI.DOMScrollOrientation.Both
• C#
// Set the grid's height and width.
C1GridView1.Height = 250;
C1GridView1.Width = 450;
// Turn scrolling on.
C1GridView1.ScrollSettings.ScrollMode = C1.Web.UI.Controls.C1GridView.C1GridViewScrollMode.ScrollBar;
// Set both horizontal and vertical scrolling.
C1GridView1.ScrollSettings.ScrollOrientation = C1.Web.UI.DOMScrollOrientation.Both;
2. Add the following code to the C1GridView's RowDataBound event which contains the information for the rows to be fixed:
Protected Sub C1GridView1_RowDataBound(ByVal sender As Object, ByVal e As C1.Web.UI.Controls.C1GridView.C1GridViewRowEventArgs) Handles C1GridView1.RowDataBound
' Fix the top three rows of the grid when scrolling horizontally.
If e.Row.RowIndex <= 2 Then
e.Row.Fixed = True
End If
End Sub
• C#
private void C1GridView1_RowDataBound(object sender, C1.Web.UI.Controls.C1GridView.C1GridViewRowEventArgs e)
{
// Fix the top three rows of the grid when scrolling horizontally.
if( e.Row.RowIndex <= 2 )
e.Row.Fixed=true;
}
What You've Accomplished
Run your application and scroll the grid. Note that the first three rows do not scroll down with the other rows.
Sample Project Available
For the complete sample, see the Scrollable sample located on the ComponentOne HelpCentral Sample page.
|