Display scheduler time 12 hour format

12 posts, 0 answers
  1. santosh
    santosh avatar
    19 posts
    Member since:
    Apr 2008

    Posted 11 Aug 2009 Link to this post

    Hi

    I want to display the day and week view in 12 hour format.

    I used the RulerTimeFormat and have set it to 12hour which displays the time in 12 hour but can't differentiate between AM and PM.

    What i want to achieve is to show AM/ PM next to the time.


    Is this posssible

    santosh
  2. Jordan
    Admin
    Jordan avatar
    547 posts

    Posted 12 Aug 2009 Link to this post

    Hi santosh,

    If you set the Culture property of RadScheduler to a culture that uses the AM / PM format like bellow, both the ruler and appointments will use it.

    this.radScheduler1.Culture = CultureInfo.CreateSpecificCulture("en-US");

    However, currently the ruler just shows the hours and not the AM / PM designators. We plan to change the ruler to show the AM / PM designators in Q3 2009 release of RadControls for WinForms.

    Greetings,
    Jordan
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. shinu rag
    shinu rag avatar
    48 posts
    Member since:
    Feb 2010

    Posted 18 Jun 2010 Link to this post

    hi Jordan ..
    i wrote this code in form's load event.
    but there isn't any change...
    can you write the complete code here...

    Thanks
    Shinu
  5. Dobry Zranchev
    Admin
    Dobry Zranchev avatar
    348 posts

    Posted 23 Jun 2010 Link to this post

    Hi shinu rag,

    Thank you for writing.

    We have a new API which allows you to apply 12 hours state to the ruler.
    this.radScheduler1.GetDayView().RulerTimeFormat = RulerTimeFormat.hours12;

    This property is available in day view, week view, work week view.

    If you have other questions, feel free to write back.

    Regards,
    Dobry Zranchev
    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
  6. shinu rag
    shinu rag avatar
    48 posts
    Member since:
    Feb 2010

    Posted 24 Jun 2010 Link to this post

    hi Jordan..
    am attached 3 images with this.

    pic-1 : Set Culture property as "English (United States)".
    pic-2 : write the code in form load event that you above posted.
    pic-3 : Output. Still the problem is there, that the AM,PM is not there along the time...

    i need 12hrs Format. its ok done, but  AM,PM is not displayed

    Thanks
    Shinu
  7. Dobry Zranchev
    Admin
    Dobry Zranchev avatar
    348 posts

    Posted 29 Jun 2010 Link to this post

    Hello shinu rag,

    Thank you for writing back. If you want to add AM/PM you should inherit the RulerRender class and draw the text that you want in the RenderHour method. The following code snippet shows how to replace the render class and what to draw in the RenderHour method:
     
    SchedulerDayViewElement dayViewElement = this.radScheduler1.SchedulerElement.ViewElement as SchedulerDayViewElement;
    dayViewElement.DataAreaElement.Ruler.RulerRenderer = new Renderer(dayViewElement.DataAreaElement.Ruler);

    public class Renderer : RulerRenderer
    {
        public Renderer(RulerPrimitive ruler)
            : base(ruler)
        {
        }
     
        public override void RenderHour(Telerik.WinControls.Paint.IGraphics g, int hour, Rectangle bounds)
        {
            using (StringFormat sf = new StringFormat())
            {
                Font font = new Font(this.ruler.Font.FontFamily, 12);
                DateTime hDate = new DateTime(2010, 1, 1, hour, 0, 0, 0);
                g.DrawString(hDate.ToString("hh t"), bounds, font, this.ruler.ForeColor, ContentAlignment.MiddleCenter, sf, Orientation.Horizontal, false);
            }
        }
    }

    Kind regards,
    Dobry Zranchev
    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
  8. shinu rag
    shinu rag avatar
    48 posts
    Member since:
    Feb 2010

    Posted 30 Jun 2010 Link to this post

    Hi Dobry Zranchev,
    Can i change this to week view too???.

    Thanks
    Shinu
  9. Dobry Zranchev
    Admin
    Dobry Zranchev avatar
    348 posts

    Posted 02 Jul 2010 Link to this post

    Hi shinu rag,

    Thank you for writing back. Yes you could use the same code snippet for day view, week view and workweek view.

    If you have other questions feel free to contact us.

    Kind regards,
    Dobry Zranchev
    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
  10. shinu rag
    shinu rag avatar
    48 posts
    Member since:
    Feb 2010

    Posted 11 Sep 2010 Link to this post

    hi Jordan ..
    here i need your help...

    i converted my application to 2010(RadControls_WinForms_2010_2_10_806_trial) version.
    after that, i got an error from the above code that you specified,

    ie Renderer.RenderHour(Telerik.WinControls.Paint.IGraphics, int, System.Drawing.Rectangle)': no suitable method found to override

    how can i overcome this problem...


    and also i have one more doubt. i upload two pics with this post
    AMPM Enabled Scheduler and AMPM Disabled Scheduler.. when i change the time format to AM and PM, there is 30  minutes difference in the ruler..
    please check my attached images .........
  11. Dobry Zranchev
    Admin
    Dobry Zranchev avatar
    348 posts

    Posted 20 Sep 2010 Link to this post

    Hello shinu rag,

    Thank you for writing back. You could just override the method RenderHour again and copy the contains from the previous RenderHour method to the new override. After that delete the previous one.

    Best wishes,
    Dobry Zranchev
    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
  12. shinu rag
    shinu rag avatar
    48 posts
    Member since:
    Feb 2010

    Posted 01 Mar 2011 Link to this post

    hi Jordan ..
    please notice this too....
    i upload two pics with this post.
    'AMPM Enabled Scheduler' and 'AMPM Disabled Scheduler'.. when i change the default time format to 12hr,
    by using this code
    private void SchedulerNew_Load(object sender, EventArgs e)
            {
                this.radCalendar1.InvalidateCalendar();
                this.radScheduler1.Culture = System.Globalization.CultureInfo.CreateSpecificCulture("en-US");
                //toolWindowSearchPatient.DockState = Telerik.WinControls.UI.Docking.DockState.AutoHide;
                SchedulerDayView dayView = this.radScheduler1.GetDayView();
                if (dayView != null)
                {
                    dayView.WorkTime = new TimeInterval(TimeSpan.FromHours(9.0), TimeSpan.FromHours(17.0));
                    dayView.RulerTimeFormat = RulerTimeFormat.hours12;
                }
                SchedulerDayViewElement dayViewElement = this.radScheduler1.SchedulerElement.ViewElement as SchedulerDayViewElement;
                dayViewElement.DataAreaElement.Table.ScrollToWorkHours();
     
              dayViewElement.DataAreaElement.Ruler.RulerRenderer = new Renderer(dayViewElement.DataAreaElement.Ruler);
     
            }
     
     
    public class Renderer : RulerRenderer
        {
            public Renderer(RulerPrimitive ruler)
                : base(ruler)
            {
            }
     
            public override void RenderHour(Telerik.WinControls.Paint.IGraphics g, int hour, Rectangle bounds)
            {
                using (StringFormat sf = new StringFormat())
                {
                    Font font = new Font(this.ruler.Font.FontFamily, 8, FontStyle.Bold);
                    DateTime hDate = new DateTime(2010, 1, 1, hour, 0, 0, 0);
                    g.DrawString(hDate.ToString("hh tt"), bounds, font, this.ruler.ForeColor, ContentAlignment.MiddleCenter, sf, Orientation.Horizontal, false);
                }
            }
     
        }

     there you can see 30 minutes difference in the time ruler..
    please check my attached images .........
  13. Dobry Zranchev
    Admin
    Dobry Zranchev avatar
    348 posts

    Posted 02 Mar 2011 Link to this post

    Hi shinu rag,

    Thank you for writing back.

    I am not able to reproduce the issue following the details of your scenario. Please open a new support ticket and send us a sample project together with a complete description of your scenario. This will help us to investigate the issue and provide you with appropriate help.

    Regards,
    Dobry Zranchev
    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
Back to Top
UI for WinForms is Visual Studio 2017 Ready