Simulating default alternating row color with columns

Posted by: j2associates on 8 September 2017, 2:04 pm EST

  • Posted 8 September 2017, 2:04 pm EST

    Hello all,

    I want to simulate alternate colors by column instead of by row. For consistency, I want to use the default alternating row color. Let's say we have several columns of related Import Data and several columns of related Export Data. I want to use the default alternating row color as the back color for alternating groups of column information.

        1. How do I programattically retrieve the alternating row default back color
        2. Is the best way to apply this color to columns creating a named style, changing the back color and applying it
        3. Is the alternating row color itself a style that I can use without alternation except for applying it to columns
        4. Can I apply a style to multiple columns simultaneously, for example something like Columns(2, 4).Style = myStyle

    Thanks in advance for any ideas and/or suggestions!


  • Replied 8 September 2017, 2:04 pm EST


    1. You may use GetCompositeInfo(row, column, altIndex, destInfo) method to get the default Alternate Row Color. e.g.

           Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
             FpSpread1.Sheets(0).AlternatingRows.Count = 3
             FpSpread1.Sheets(0).AlternatingRows(0).BackColor = Color.RoyalBlue
             FpSpread1.Sheets(0).AlternatingRows(0).ForeColor = Color.White
             FpSpread1.Sheets(0).AlternatingRows(1).BackColor = Color.LightYellow
             FpSpread1.Sheets(0).AlternatingRows(1).ForeColor = Color.Navy
             FpSpread1.Sheets(0).AlternatingRows(2).BackColor = Color.Salmon
             FpSpread1.Sheets(0).AlternatingRows(2).ForeColor = Color.Green
             Dim ssm As FarPoint.Win.Spread.Model.ISheetStyleModel
             Dim si As FarPoint.Win.Spread.StyleInfo
             ssm = FpSpread1.ActiveSheet.Models.Style
             si = ssm.GetCompositeInfo(0, 1, 2, Nothing)
           End Sub

    2.Yes, creating a named style is a good choice to apply Color to Column/Columns.

    3.There are different ways available to apply Alternate Row Style.

    One is using SetDirectAltRowInfo( ) , which sets the specified alternating row style in the model.

    And other is using AlternatingRow Class members. e.g. BackColor, ForeColor, Font, CellType etc.

    I don't think that these ways can be used without alternation.

    4.Yes, you can apply a style to multiple Columns simultaneously. I successfully applied the style to a group of columns using the following code,

            Dim ns As New FarPoint.Win.Spread.NamedStyle("StyleColumns")
            ns.BackColor = Color.Aqua
            FpSpread1.Sheets(0).Columns(2, 5).StyleName = "StyleColumns"

    I hope I was able to answer all of your questions.







  • Replied 8 September 2017, 2:04 pm EST

    Thanks DeepakSharma, that was very helpful! Does the spread itself not have a default alternating color? If it does, how do I get it, if not, do you know what the default Excel alternating color is? Also, I fat fingered #3 above in my original post. I meant without alteration. If there is a default alternating color style for the spread, can I manually through code get that default style and then apply it to columns as described above, again in code? Thanks again for the very helpful response!
  • Replied 8 September 2017, 2:04 pm EST


    In order to find the Default AlternatingRow Color you may try this:

    At design time, in the Properties window, select the FarPoint Spread component.
        Select the Sheets property.
        Click the button to display the SheetView Collection Editor.
        Select the sheet for which you want to create alternating rows from the collection list.
        Select the AlternatingRows property from the property list for that sheet.
        You will see the default Back and Fore Color, 
        Which I see is "White"(Blank)

    In order to find the same thing for Excel you may try this:
        Open an Excel Sheet.
        Select the range you want to format.
        On the Format menu, click AutoFormat.
        Click the preview image of the List1 autoformat.
        Select it and click Ok.
        You will be able to find the AlternateRow Color.

    I don't see a way to Reach that default AlternatingRow Color for Spread through Code.





Need extra support?

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

Learn More

Forum Channels