Applying custom style to cell or row

Posted by: pragati-sd-fp on 10 September 2017, 10:56 am EST

  • Posted 10 September 2017, 10:56 am EST

    Hello,
    I've the string with setter values of style like this -



    With this, how can I set the style for a cell or a row? Rather, how can I set the style with StyleName property?

    Please, help.

    Thanks,
    Pragati.
  • Replied 10 September 2017, 10:56 am EST

    Hello,

    You can set the style for a cell using StyleName property using:

    gcSpreadSheet1.NamedStyles.Add(new GrapeCity.Windows.SpreadSheet.Data.StyleInfo() { Background = new SolidColorBrush(Colors.Red), Name = "aaa", VerticalAlignment = GrapeCity.Windows.SpreadSheet.Data.CellVerticalAlignment.Center} );
    gcSpreadSheet1.Sheets[0].Cells[0, 0].StyleName = "aaa";

     

    Thanks,

  • Replied 10 September 2017, 10:56 am EST

    Hello,

    Thanks for your reply. Its really useful.

    But, how about my first question? If I'm having the string of setters like that, I've to split that string, check the cases (like for FontStyle - Normal & Italic) and then assign it in StyleInfo. Is there any simple way? Like, I'll have a style with those setters & that style I can get added in NamedStyles?

    Please, help.

    Thanks,
    Pragati.
  • Replied 10 September 2017, 10:56 am EST

    Do you mean you want to use WPF/Silverlight Style in XAML to set style of a cell/row/column?
  • Replied 10 September 2017, 10:56 am EST

    Hello,

    Actually, I've the styles saved in Database with the format -


    So, I was asking how I can use this string to set the style for a row?

    Thanks,
    Pragati.

  • Replied 10 September 2017, 10:56 am EST

    I think you have to write code to parse this string, and map each property of each Setter to property of StyleInfo, and set each value accordingly.
Need extra support?

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

Learn More

Forum Channels