Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
181
How to add custom button in a day slot in monthviewsingle calendar?
posted

Hi i have some questions in monthviewsingle calendar

1.In my application,when user double click a particular day slot,i am opening my custom appiontment form(using this event ultraCalendarInfo1_BeforeDisplayAppointmentDialog i am cancel the default appionment form).Once user enter the appiontement detail and click the save and close button,i have to show a custom button in the particular day slot.By the way user can add any numberof schedules in the day slot(i have to show all appiontment detail in that  day slot)

2.Is it possible to expand the particular week size?(If week 1,day 3 have 5 appiontments, then i have to  expand that week1's height (from day 1 to 7 )and show all appiontments in day 3,and all the other week that is from week 2 to 5 have default week size(assume week 2 to 5 dont have more than one schedule))

i need it urgently. any help will be appriciated.

Thanks in advance,

Shan

Parents
No Data
Reply
  • 356
    posted

    Hi,

    Maybe you already found a solution, but I had the same problem, and here is my solution to Insert a Button in the WinSchedule (UltraDayView, UltraMonthViewSingle and UltraWeekView).

    Create the following class:

    using Infragistics.Win;
    using Day=Infragistics.Win.UltraWinSchedule.DayView;
    using Month=Infragistics.Win.UltraWinSchedule.MonthViewSingle;

    public class ClickToAddAppointmentCreationFilter : IUIElementCreationFilter
        {
            private AppearanceBase appearance = null;

            public ClickToAddAppointmentCreationFilter(AppearanceBase appearance)
            {
                if (appearance == null)
                    throw new ArgumentNullException("appearance");

                this.appearance = appearance;
            }

            #region IUIElementCreationFilter Members

            void IUIElementCreationFilter.AfterCreateChildElements(UIElement parent)
    { return; }

    bool IUIElementCreationFilter.BeforeCreateChildElements(UIElement parent)
            {
                if (parent is TextUIElement)
                {
                    TextUIElement textElement = parent as TextUIElement;
                    if (textElement.Text == "keyTextToReplaceByTheButton")
                    {

                        return replaceControls(parent);
                       
                    }
                }

                return false;
            }


            private bool replaceControls(UIElement parent)
            {
                UIElement replaceThis = parent.GetAncestor(typeof(Day.AllDayEventUIElement));
                if (replaceThis == null)
                {
                    replaceThis = parent.GetAncestor(typeof(Month.SingleDayAppointmentUIElement));
                    if (null == replaceThis)
                        return false;
                }

                DerivedButtonUIElement withThis = new DerivedButtonUIElement(replaceThis, this.appearance);
                replaceThis.Parent.ChildElements.Add(withThis);
                replaceThis.Parent.ChildElements.Remove(replaceThis);

                withThis.Rect = replaceThis.Rect;

                return true;
            }

            #endregion


            public class DerivedButtonUIElement : ButtonUIElement
            {
                private AppearanceBase appearance = null;

                public DerivedButtonUIElement(UIElement parent, AppearanceBase appearance)
                    : base(parent)
                {
                    this.appearance = appearance;
                    this.Text = "ButtonText";

                    this.ElementClick += new UIElementEventHandler(b_ElementClick);
                }

                protected override void InitAppearance(ref AppearanceData appearance, ref AppearancePropFlags requestedProps)
                {
                    requestedProps = AppearancePropFlags.AllRender;
                    this.appearance.MergeData(ref appearance, ref requestedProps);
                }

                void b_ElementClick(object sender, UIElementEventArgs e)
                {
                    //Click Action
                }
            }
        }

    than assign the filters in the form load:

    private void Form2_Load(object sender, System.EventArgs e)
            {
                Infragistics.Win.Appearance appearance = new Infragistics.Win.Appearance();
    //  Set the appearance properties of interest...


                this.ultraDayView1.CreationFilter = new ClickToAddAppointmentCreationFilter(appearance);
                this.ultraMonthViewSingle1.CreationFilter = new ClickToAddAppointmentCreationFilter(appearance);
                this.ultraWeekView1.CreationFilter = new ClickToAddAppointmentCreationFilter(appearance);

    }

     

Children
No Data