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

    <P>Hello all,</P>
    <P>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.</P>
    <P>    1. How do I programattically retrieve the alternating row default back color<BR>    2. Is the best way to apply this color to columns creating a named style, changing the back color and applying it <BR>    3. Is the alternating row color itself a style that I can use without alternation except for applying it to columns<BR>    4. Can I apply a style to multiple columns simultaneously, for example something like Columns(2, 4).Style = myStyle</P>
    <P>Thanks in advance for any ideas and/or suggestions!</P>
    <P><BR> </P>
  • Replied 8 September 2017, 2:04 pm EST

    <p>Hello,</p><p>1. You may use GetCompositeInfo(row, column, altIndex, destInfo) method to get the default Alternate Row Color. e.g.</p><p>       Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load <br>         FpSpread1.Sheets(0).AlternatingRows.Count = 3<br>         FpSpread1.Sheets(0).AlternatingRows(0).BackColor = Color.RoyalBlue<br>         FpSpread1.Sheets(0).AlternatingRows(0).ForeColor = Color.White<br>         FpSpread1.Sheets(0).AlternatingRows(1).BackColor = Color.LightYellow<br>         FpSpread1.Sheets(0).AlternatingRows(1).ForeColor = Color.Navy<br>         FpSpread1.Sheets(0).AlternatingRows(2).BackColor = Color.Salmon<br>         FpSpread1.Sheets(0).AlternatingRows(2).ForeColor = Color.Green<br>    <br>         Dim ssm As FarPoint.Win.Spread.Model.ISheetStyleModel<br>         Dim si As FarPoint.Win.Spread.StyleInfo<br>         ssm = FpSpread1.ActiveSheet.Models.Style<br>         si = ssm.GetCompositeInfo(0, 1, 2, Nothing)<br>         MsgBox(si.BackColor.ToString())<br>    <br>       End Sub</p><p>2.Yes, creating a named style is a good choice to apply Color to Column/Columns.</p><p>3.There are different ways available to apply Alternate Row Style.</p><p>One is using SetDirectAltRowInfo( ) , which sets the specified alternating row style in the model.</p><p>And other is using AlternatingRow Class members. e.g. BackColor, ForeColor, Font, CellType etc.</p><p>I don't think that these ways can be used without alternation.</p><p>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,</p><p>        Dim ns As New FarPoint.Win.Spread.NamedStyle("StyleColumns")<br>        ns.BackColor = Color.Aqua<br>        FpSpread1.NamedStyles.Add(ns)<br>        FpSpread1.Sheets(0).Columns(2, 5).StyleName = "StyleColumns"<br> </p><p>I hope I was able to answer all of your questions.</p><p>Thanks,</p><p> </p><p> </p><p> </p><p> </p><p> </p>
  • 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

    <p>Hello, </p><p>In order to find the Default AlternatingRow Color you may try this:</p><p>At design time, in the Properties window, select the FarPoint Spread component. <br>    Select the Sheets property. <br>    Click the button to display the SheetView Collection Editor. <br>    Select the sheet for which you want to create alternating rows from the collection list. <br>    Select the AlternatingRows property from the property list for that sheet.<br>    You will see the default Back and Fore Color,  <br>    Which I see is "White"(Blank)</p><p>In order to find the same thing for Excel you may try this:<br>    Open an Excel Sheet.<br>    Select the range you want to format.<br>    On the Format menu, click AutoFormat.<br>    Click the preview image of the List1 autoformat.<br>    Select it and click Ok.<br>    You will be able to find the AlternateRow Color.</p><p>I don't see a way to Reach that default AlternatingRow Color for Spread through Code. </p><p> </p><p>Thanks,</p><p> </p><p> </p>
Need extra support?

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

Learn More

Forum Channels