Spread Windows Forms 11.0 Product Documentation
MergePolicy Enumeration
Example Example 


FarPoint.Win.Spread Assembly > FarPoint.Win.Spread.Model Namespace : MergePolicy Enumeration
Specifies how the control handles automatic merging of cells based on the values in the cells.
Syntax
'Declaration
 
Public Enum MergePolicy 
   Inherits System.Enum
'Usage
 
Dim instance As MergePolicy
public enum MergePolicy : System.Enum 
Members
MemberDescription
AlwaysAlways automatically merges neighboring cells with identical values
NoneNever automatically merges cells
RestrictedAutomatically merges cells neighboring cells with identical values if the corresponding cells in another row or column are similarly merged
Remarks

To allow adjacent identical cells to be merged automatically, set the MergePolicy to Always or Restricted.

For more information on automatic merging of cells, refer to Allowing Cells to Merge Automatically.

If you are using a specific cell type, be careful of restrictions for that cell type. For example, in order for automatic merging to work with CheckBox cells, the Value needs to be set to true or false instead of 1 or 0.

Example
This example fills a bunch of cells and then illustrates merging of adjacent cells with the same content.
fpSpread1.ActiveSheet.RowCount = 12;
fpSpread1.ActiveSheet.ColumnCount = 5;
fpSpread1.ActiveSheet.Columns[1].Width = 150;
fpSpread1.ActiveSheet.SetClip(0, 0, 1, 5, "VS Live\tSan Francisco\tScott\tScott\t12:00");
fpSpread1.ActiveSheet.SetClip(1, 0, 1, 5, "VS Live\tSan Francisco\tScott\tChris\t12:00");
fpSpread1.ActiveSheet.SetClip(2, 0, 1, 5, "VS Live\tSan Francisco\tScott\tChris\t1:00");
fpSpread1.ActiveSheet.SetClip(3, 0, 1, 5, "MSCE\tSan Francisco\tScott\tScott\t12:00");
fpSpread1.ActiveSheet.SetClip(4, 0, 1, 5, "VS Live\tOrlando\tChris\tChris\t1:00");
fpSpread1.ActiveSheet.SetClip(5, 0, 1, 5, "VS Live\tOrlando\tScott\tChris\t2:00");
fpSpread1.ActiveSheet.SetClip(6, 0, 1, 5, "VS Live\tNew York\tGreg\tGreg\t2:00");
fpSpread1.ActiveSheet.SetClip(7, 0, 1, 5, "VS Live\tNew York\tGreg\tJim\t2:00");
fpSpread1.ActiveSheet.SetClip(8, 0, 1, 5, "VS Live\tNew York\tGreg\tJim\t3:00");
fpSpread1.ActiveSheet.SetClip(9, 0, 1, 5, "VS Live\tNew York\tScott\tJim\t4:00");
fpSpread1.ActiveSheet.SetClip(10, 0, 1, 5, "PRN\tRaleigh\tScott\tScott\t7:00");
fpSpread1.ActiveSheet.SetClip(11, 0, 1, 5, "PRN\tCary\tJenny\tRyan\t6:00");
DialogResult dlg; 
dlg = MessageBox.Show("Do you want to merge the data?", "GetColumnMerge", MessageBoxButtons.YesNo);
if (dlg == DialogResult.Yes)
{
fpSpread1.ActiveSheet.SetRowMerge(-1, FarPoint.Win.Spread.Model.MergePolicy.Always);
fpSpread1.ActiveSheet.SetColumnMerge(-1, FarPoint.Win.Spread.Model.MergePolicy.Always);
fpSpread1.SetBounds(fpSpread1.Bounds.X, fpSpread1.Bounds.Y, fpSpread1.Bounds.Width + 1, fpSpread1.Bounds.Height);
label1.Text = fpSpread1.ActiveSheet.GetColumnMerge(-1).ToString();
}
With FpSpread1.ActiveSheet
.RowCount = 12
.ColumnCount = 5
.Columns(1).Width = 150
.SetClip(0, 0, 1, 5, "VS Live" & vbTab & "San Francisco" & vbTab & "Scott" & vbTab & "Scott" & vbTab & "12:00")
.SetClip(1, 0, 1, 5, "VS Live" & vbTab & "San Francisco" & vbTab & "Scott" & vbTab & "Chris" & vbTab & "12:00")
.SetClip(2, 0, 1, 5, "VS Live" & vbTab & "San Francisco" & vbTab & "Scott" & vbTab & "Chris" & vbTab & "1:00")
.SetClip(3, 0, 1, 5, "MSCE" & vbTab & "San Francisco" & vbTab & "Scott" & vbTab & "Scott" & vbTab & "12:00")
.SetClip(4, 0, 1, 5, "VS Live" & vbTab & "Orlando" & vbTab & "Chris" & vbTab & "Chris" & vbTab & "1:00")
.SetClip(5, 0, 1, 5, "VS Live" & vbTab & "Orlando" & vbTab & "Scott" & vbTab & "Chris" & vbTab & "2:00")
.SetClip(6, 0, 1, 5, "VS Live" & vbTab & "New York" & vbTab & "Greg" & vbTab & "Greg" & vbTab & "2:00")
.SetClip(7, 0, 1, 5, "VS Live" & vbTab & "New York" & vbTab & "Greg" & vbTab & "Jim" & vbTab & "2:00")
.SetClip(8, 0, 1, 5, "VS Live" & vbTab & "New York" & vbTab & "Greg" & vbTab & "Jim" & vbTab & "3:00")
.SetClip(9, 0, 1, 5, "VS Live" & vbTab & "New York" & vbTab & "Scott" & vbTab & "Jim" & vbTab & "4:00")
.SetClip(10, 0, 1, 5, "PRN" & vbTab & "Raleigh" & vbTab & "Scott" & vbTab & "Scott" & vbTab & "7:00")
.SetClip(11, 0, 1, 5, "PRN" & vbTab & "Cary" & vbTab & "Jenny" & vbTab & "Ryan" & vbTab & "6:00")
End With
Dim dlg As DialogResult
dlg = MessageBox.Show("Do you want to merge the data?", "GetColumnMerge", MessageBoxButtons.YesNo)
If dlg = DialogResult.Yes Then
FpSpread1.ActiveSheet.SetRowMerge(-1, FarPoint.Win.Spread.Model.MergePolicy.Always)
FpSpread1.ActiveSheet.SetColumnMerge(-1, FarPoint.Win.Spread.Model.MergePolicy.Always)
FpSpread1.SetBounds(FpSpread1.Bounds.X, FpSpread1.Bounds.Y, FpSpread1.Bounds.Width + 1, FpSpread1.Bounds.Height)
Label1.Text = FpSpread1.ActiveSheet.GetColumnMerge(-1).ToString()
End If
Inheritance Hierarchy

System.Object
   System.ValueType
      System.Enum
         FarPoint.Win.Spread.Model.MergePolicy

See Also

Reference

FarPoint.Win.Spread.Model Namespace
MergePolicy Property (Column Class)
MergePolicy Property (Row Class)

User-Task Documentation

Allowing Cells to Merge Automatically