Problems with BackColor

4 posts, 0 answers
  1. Sean Overman
    Sean Overman avatar
    31 posts
    Member since:
    Sep 2012

    Posted 28 Apr 2011 Link to this post

    I'm using the following method to change the background colors on my scheduler cells.

    List<SchedulerDayViewElement> dayViews = ((SchedulerDayViewGroupedByResourceElement)radScheduler1.SchedulerElement.ViewElement).GetDayViewElements();
    foreach (SchedulerDayViewElement dve in dayViews) {
        foreach (SchedulerCellElement sce in dve.DataAreaElement.Table.GetCells()) {
            sce.BackColor = Color.FromArgb(230, 230, 230);
        }
    }

    This is a simplified example, as I have more logic in my application to figure out what colors certain cells should be.

    The problem is when I set that BackColor property the whole cell gets all whacked out.   From what I can tell, not only is it changing the backcolor, but also the "hoverbackcolor" and the "selectedbackcolor", both of which I have no idea how to set.  Or not set, for that matter.

    Also, what is BackColor2, BackColor3, BackColor4?
  2. Ivan Todorov
    Admin
    Ivan Todorov avatar
    688 posts

    Posted 29 Apr 2011 Link to this post

    Hello Sean Overman,

    Thank you for contacting us.

    The hover and selected back colors are set through the theme (using Visual Style Builder). When you set a property explicitly, it has higher priority than the theme settings. That is why by setting the BackColor you loose the hovered and selected state settings.

    As to your second question, the BackColor, BackColor2, BackColor3 and BackColor4 are used to set gradient colors (along with the GradientStyle, GradientAngle and GradientPercentage) properties.

    If you can give me some more details about the reason why you want to change cells' back colors, I can try to provide a solution for this case.

    I hope this helps. Feel free to write back if you have any additional questions.

    Best wishes,
    Ivan Todorov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Shawn Shaddock
    Shawn Shaddock avatar
    25 posts
    Member since:
    Jun 2009

    Posted 09 Feb 2012 Link to this post

    I need to do something similar. I am making an appointment scheduler and our users like to see the top of the hour cells in a different color to make navigating and booking appointments easier. For example the cells that fall at 9 AM, 10 AM, 11 AM, etc... would be shaded blue.
  5. Ivan Todorov
    Admin
    Ivan Todorov avatar
    688 posts

    Posted 13 Feb 2012 Link to this post

    Hi Shawn,

    Thank you for your question.

    You can use the CellFormatting event of RadScheduler to achieve this:
    void radScheduler1_CellFormatting(object sender, SchedulerCellEventArgs e)
    {
        if (e.CellElement.Date.Hour >= 10 && e.CellElement.Date.Hour <=12)
        {
            e.CellElement.BackColor = Color.Aquamarine;
        }
    }

    I hope you find it useful.

    Kind regards,
    Ivan Todorov
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Back to Top