Skip to content

Infragistics Community Forum / Web / Ignite UI for ASP.NET Core / how to set CellFormat.FillPatternForegroundColor for the version of 20.2 InfragisticsWPF4

how to set CellFormat.FillPatternForegroundColor for the version of 20.2 InfragisticsWPF4

New Discussion
Weimin Zhang
Weimin Zhang asked on Apr 4, 2024 5:06 AM

I have a dotnet framework windows gui app using InfragisticsWPF4.v20.2 upgraded from V14.1, where the following code was working for V14.1, but not working any more even in compiling:

excelWorkSheetRow.Cells[i + level].CellFormat.FillPatternForegroundColor = System.Drawing.Color.LightGray;

Cannot implicitly convert type ‘System.Drawing.Color’ to ‘System.Windows.Media.Color’.

same to CellFormat.BottomBorderColor, CellFormat.LeftBorderColor, and CellFormat.FillPatternForegroundColor

excelWorkSheetRow.Cells[i + level].CellFormat.FillPattern = FillPatternStyle.Solid;

CellFormat.FillPattern is obsolete, it suggests to use Fill – how to?

Please help with some samples. Thanks!

 

 

Sign In to post a reply

Replies

  • 0
    Tihomir Tonev
    Tihomir Tonev answered on Aug 17, 2021 2:07 PM

    Hello,

    Thank you for posting on our forums.

    Please note that as per the information in our documentation:

    Note:

    In previous versions, the cell fill was defined by three properties on the IWorksheetCellFormat interface: FillPattern, FillPatternBackgroundColor, and FillPatternForegroundColor. They are all replaced by a single Fill property, which is a reference to a CellFill instance.

    https://www.infragistics.com/help/wpf/excelengine-excel-2007-color-model#_Ref320715825

    Please check the above link for further information how to set the fill of a cell.

    If you have further questions or concerns, please let me know

    Sincerely,

    Tihomir Tonev
    Associate Software Developer
    Infragistics

    • 0
      Weimin Zhang
      Weimin Zhang answered on Aug 17, 2021 3:18 PM

      Hi Tihomir Tonev,

      Thanks for your quick reply. Can you please share me with some sample how to set Fill property to replace FillPatternForegroundColor, LeftBorderColor, FillPatternForegroundColor, and FillPattern in C#? Thanks!

      • 0
        Ivan Kitanov
        Ivan Kitanov answered on Aug 18, 2021 11:31 AM

        Hello Weimin,

        The CellFormat.Fill basically combines the three properties that you have mentioned above. It could be used as follows with the CreatePatterFill method, which takes 3 arguments – BackGroundColor, PatternColor and FillPaternStyle:

        worksheet1.Rows[0].Cells[0].CellFormat.Fill = CellFill.CreatePatternFill(Color.FromRgb(152, 251, 152), Color.FromRgb(0, 0, 0), FillPatternStyle.Solid);

        I have also created a small sample application that demonstrates how the Fill property could be applied as well as applying border to the cells.

        Please test the sample on your side let me know if you have any questions.

        Regards, Ivan Kitanov

      • 0
        Weimin Zhang
        Weimin Zhang answered on Aug 18, 2021 3:25 PM

        Hi Ivan,

        Thanks for your sample code. Just wonder now CreatePatternFille() accepts System.Windows.Media.Color as for the foreground/background colors, where you provided Color.FromRgb(152,251,152), how to use System.Drawing.Color, such as, System.Drawing.Color.LightGray, etc? Do they have any function/method to convert from System.Drawing.Color to System.Windows.Media.Color? It is not convenient to use FromRgb() with 3 individual color elements. Please advise. Thanks!

      • 0
        Ivan Kitanov
        Ivan Kitanov answered on Aug 19, 2021 6:29 AM

        Hello Weimin,

        In order to convert from System.Drawing.Color to System.Windows.Media.Color you can use the FromArgb method of the System.Windows.Media.Color and pass the System.Drawing.Color, form it you can obtain the a,r,g and b similar to the code below:

        System.Drawing.Color color;

        System.Windows.Media.Color newColor = System.Windows.Media.Color.FromArgb(color.A, color.R, color.G, color.B);

        I also recommend you reviewing the following stackoverflow post, that explains in in more details and provides an example of implementing this approach for frequent uses.

        Regards,
        Ivan Kitanov

      • 0
        Weimin Zhang
        Weimin Zhang answered on Aug 19, 2021 12:28 PM

        Hi Ivan,

        Thanks a lot for the quick solution. That's exactly what I wanted. Thanks again, and have great day!

        Weimin

      • 0
        Ivan Kitanov
        Ivan Kitanov answered on Aug 19, 2021 2:12 PM

        Hello Wimin,

        I’m glad that you found my suggestion helpful and managed to resolve you issue.

        Thank you for choosing Infragistics!

        Regards,
        Ivan Kitanov

  • You must be logged in to reply to this topic.
Discussion created by
Favorites
Replies
Created On
Last Post
Discussion created by
Weimin Zhang
Favorites
0
Replies
7
Created On
Apr 04, 2024
Last Post
5 years, 2 months ago

Suggested Discussions

Created by

Created on

Apr 4, 2024 5:06 AM

Last activity on

Feb 23, 2026 10:00 AM