Merge a column with same text

Posted by: cvetx on 8 September 2017, 1:49 pm EST

  • Posted 8 September 2017, 1:49 pm EST

    I have a cloumn that has ten row on a sheet. Let's say there are only two text on the column which are "GM" and "Ford". Those are repeated on the sheet. How do I merge columns two see only a GM and Ford?


     Thanks.

  • Replied 8 September 2017, 1:49 pm EST

    Hello,

    You may use the merge policy which when is set to Always, implies that cells within a row or column are merged when the cells have the same values. The below snippet will get the desired behavior:

            FpSpread1_Sheet1.RowCount = 10
            FpSpread1_Sheet1.ColumnCount = 2
            FpSpread1.ActiveSheet.Cells(0, 0).Value = "GM"
            FpSpread1.ActiveSheet.Cells(0, 1).Value = "Ford"
            FpSpread1.ActiveSheet.Cells(1, 0).Value = "GM"
            FpSpread1.ActiveSheet.Cells(1, 1).Value = "GM"
            FpSpread1.ActiveSheet.Cells(2, 0).Value = "FORD"
            FpSpread1.ActiveSheet.Cells(2, 1).Value = "FORD"
            FpSpread1.ActiveSheet.Cells(3, 0).Value = "FORD"
            FpSpread1.ActiveSheet.Cells(3, 1).Value = "FORD"
            FpSpread1.ActiveSheet.Cells(4, 0).Value = "GM"
            FpSpread1.ActiveSheet.Cells(4, 1).Value = "GM"
            FpSpread1.ActiveSheet.Cells(5, 0).Value = "GM"
            FpSpread1.ActiveSheet.Cells(5, 1).Value = "Ford"
            FpSpread1.ActiveSheet.Cells(6, 0).Value = "GM"
            FpSpread1.ActiveSheet.Cells(6, 1).Value = "GM"
            FpSpread1.Sheets(0).SetColumnMerge(-1, FarPoint.Win.Spread.Model.MergePolicy.Always)

    Hope this helps.Thanks

  • Replied 8 September 2017, 1:49 pm EST

    Thanks for the reply and that worked out well. I have question here.


    --> The merged value is staying in the middle of the column and it moves by scrolling a sheet, so I can't see the value if the page is longer than display. Can I make it always stay on top of the column even though the sheet is scrolled?


     

  • Replied 8 September 2017, 1:49 pm EST

    Hello,

    I am not sure, if i have understoond the requirement correctly, however if you wishes to freeze rows/column while scrolling the sheet(so that you can see the values, if page is longer), you may done so using the FrozenRowCount and FrozenColumnCount properties of the control.In case meets the requirement, then you may use the following:

            FpSpread1.Sheets(0).FrozenColumnCount = 5
            FpSpread1.Sheets(0).FrozenRowCount = 5

    Thanks.

  • Replied 8 September 2017, 1:49 pm EST

    Hello,


    There is not a way to do this in the Spread for Windows Forms product.

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels