GrapeCity MultiRow Windows Forms Documentation
Assigning and Allocating a Template

Rows with the same layout as the template are created at runtime by assigning a template to the GcMultiRow control. The template assigned to the grid is read-only. In order to change the template you need to reassign it to the grid.

Assigning a Template

Use the GcMultiRow.Template property to assign a template to the grid. You can assign an instance of the Template class or an instance of the class inherited from the Template class to the Template property.

Using Code

The following code assigns an empty template.

[VB]

GcMultiRow1.Template = New GrapeCity.Win.MultiRow.Template()

[CS]

gcMultiRow1.Template = new GrapeCity.Win.MultiRow.Template();
The current values in the grid are discarded when a template is assigned to the grid. If the grid is bound to data, the values are reloaded. In unbound mode, you can set the GcMultiRow.RestoreValue property to True to restore the cell values once the template is changed.

Assigning Default Template

When the GcMultiRow control is placed on a form using the Visual Studio form designer, it is placed without a template. To set the default template using the form designer, select "Default Template" from the smart tag. You can use the Template.Default property to set the default template while creating a template with code.

Using Code

This example sets the default template.

[VB]

GcMultiRow1.Template = GrapeCity.Win.MultiRow.Template.Default

[CS]

gcMultiRow1.Template = GrapeCity.Win.MultiRow.Template.Default;

Referencing a Template

Refer to the Template class instance with the GcMultiRow.Template property to reference the template assigned to the grid.

Using Code

The following code lists the current column width of the grid and the column width of the template.

[VB]

Imports GrapeCity.Win.MultiRow

' Set the default template. 
GcMultiRow1.Template = Template.Default
' Change the cell width.
GcMultiRow1.Rows(0).Cells(1).HorizontalResize(100)

Console.WriteLine("Width of template cell: {0}", GcMultiRow1.Template.Row.Cells(1).Width)
Console.WriteLine("Width of grid cell: {0}", GcMultiRow1.Rows(0).Cells(1).Width)

[CS]

using GrapeCity.Win.MultiRow;

// Set the default template.
gcMultiRow1.Template = Template.Default;
// Change the cell width.
gcMultiRow1.Rows[0].Cells[1].HorizontalResize(100);

Console.WriteLine("Width of template cell: {0}", gcMultiRow1.Template.Row.Cells[1].Width);
Console.WriteLine("Width of grid cell: {0}", gcMultiRow1.Rows[0].Cells[1].Width);
If you have changed the Template class instance with the GcMultiRow.Template property, this change will not be reflected in the grid. To reflect the change, you need to reassign the template.
See Also

 

 


Copyright © GrapeCity, inc. All rights reserved.

Support Options