Can edit elements in RadControlSpy, but how to do programmatically?

0 Answers 74 Views
Scheduler and Reminder
Thomas
Top achievements
Rank 1
Thomas asked on 09 Jan 2023, 07:04 AM

RadControlSpy

So if I wanted to modify a value (example: Visible = Collapse) in this highlighted element of RadScheduler. How do I do that? 

Dess | Tech Support Engineer, Principal
Telerik team
commented on 09 Jan 2023, 07:10 AM

Hello, Thomas,

You have access to the SchedulerHeaderCellElement in the CellFormatting event. However, note that the visual cell elements are being reused during operations like scrolling. Hiding the cells is not recommended. That is why I would kindly ask you to provide more details about the exact goal that you are trying to achieve? Thus, we would get better understanding of the precise case and think about an appropriate solution. Thank you in advance. I am looking forward to your reply.

Thomas
Top achievements
Rank 1
commented on 09 Jan 2023, 03:42 PM

Here is my grid (guide). The areas in purple are the elements I am trying to change. I know they are in different classes. I am trying to determine which classes so I can modify them in the cell format event. I have posed my current cell format method below.


 private void RadScheduler1_CellFormatting(object sender, SchedulerCellEventArgs e)
        {
            Font Hfont = new Font("Segoe UI", 20f, FontStyle.Regular);
            Font Cfont = new Font("Segoe UI", 18f, FontStyle.Regular);

            if (e.CellElement is SchedulerCellElement)
            {
                e.CellElement.BackColor = Color.FromArgb(57, 74, 83);
            }

            // A CELLS
            if (e.CellElement is SchedulerHeaderCellElement)
            {
                e.CellElement.Font = Cfont;
                e.CellElement.ForeColor = Color.FromArgb(166, 170, 171);
                e.CellElement.TextAlignment = ContentAlignment.MiddleLeft;
                e.CellElement.BorderColor = Color.FromArgb(0, 255, 0);
                e.CellElement.BorderBoxStyle = BorderBoxStyle.SingleBorder;
                e.CellElement.BorderWidth = 0;
                e.CellElement.DrawFill = true;
                e.CellElement.BackColor = Color.FromArgb(57, 74, 83);
                e.CellElement.GradientStyle = GradientStyles.Solid;
            }

            // RESOURCE HEADER
            if (e.CellElement is SchedulerResourceHeaderCellElement)
            {
                e.CellElement.Font = Hfont;
                e.CellElement.ForeColor = Color.FromArgb(255, 255, 255);
                e.CellElement.BackColor = Color.FromArgb(43, 56, 62);
                e.CellElement.TextAlignment = ContentAlignment.MiddleCenter;
                e.CellElement.TextOrientation = Orientation.Horizontal;
                e.CellElement.GradientStyle = GradientStyles.Solid;
                radScheduler1.SchedulerElement.SetResourceHeaderAngleTransform(SchedulerViewType.Timeline, 0);
                e.CellElement.BorderColor = Color.FromArgb(43, 56, 62);
                e.CellElement.BorderBoxStyle = BorderBoxStyle.SingleBorder;
                e.CellElement.BorderWidth = 4;
                e.CellElement.BorderGradientStyle = GradientStyles.Solid;
                e.CellElement.DrawFill = true;
            }
        }

Dess | Tech Support Engineer, Principal
Telerik team
commented on 12 Jan 2023, 08:43 AM

Hello, Thomas,

Note that the Font creation is a time-consuming operation and the CellFormatting event is expected to be fired many times. That is why it is recommended to create the fonts outside the CellFormatting event handler and just use the variables when formatting the cells.

As to the question at hand, please have in mind that the SchedulerHeaderCellElement and the SchedulerResourceHeaderCellElement are derivatives of SchedulerCellElement. Hence, all the customization logic for these cell types should be executed before the default condition. It is also necessary to use if-else-if-else structure instead of only if statements because thus several if conditions may be matched and style settings applied to undesired elements. Last, but not least, scheduler cell elements are created only for currently visible cells and are being reused during operations like scrolling. In order to prevent applying the formatting to other cell elements (because of the cell reuse), all customization should be reset for the rest of the cell elements. In other words, each "if" statement should have its "else" clause for resetting the previously applied styles settings like it is demonstrated in the help article:
https://docs.telerik.com/devtools/winforms/controls/gridview/cells/formatting-cells 

I hope this information helps.
Thomas
Top achievements
Rank 1
commented on 16 Jan 2023, 07:28 AM

Thank you. I have moved the create fonts outside the CellFormatting event handler as suggested. I corrected the if only statements to the if-else-if-else structure.

No answers yet. Maybe you can help?

Tags
Scheduler and Reminder
Asked by
Thomas
Top achievements
Rank 1
Share this question
or