This is a migrated thread and some comments may be shown as answers.

Display scheduler time 12 hour format

11 Answers 213 Views
Scheduler and Reminder
This is a migrated thread and some comments may be shown as answers.
santosh
Top achievements
Rank 1
santosh asked on 11 Aug 2009, 12:52 PM
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

11 Answers, 1 is accepted

Sort by
0
Jordan
Telerik team
answered on 12 Aug 2009, 09:44 AM
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.
0
shinu rag
Top achievements
Rank 1
answered on 18 Jun 2010, 12:42 PM
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
0
Dobry Zranchev
Telerik team
answered on 23 Jun 2010, 07:21 PM
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
0
shinu rag
Top achievements
Rank 1
answered on 24 Jun 2010, 11:19 AM
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
0
Dobry Zranchev
Telerik team
answered on 29 Jun 2010, 02:27 PM
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
0
shinu rag
Top achievements
Rank 1
answered on 30 Jun 2010, 06:42 AM
Hi Dobry Zranchev,
Can i change this to week view too???.

Thanks
Shinu
0
Dobry Zranchev
Telerik team
answered on 02 Jul 2010, 04:37 PM
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
0
shinu rag
Top achievements
Rank 1
answered on 11 Sep 2010, 10:20 AM
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 .........
0
Dobry Zranchev
Telerik team
answered on 20 Sep 2010, 10:00 AM
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
0
shinu rag
Top achievements
Rank 1
answered on 01 Mar 2011, 11:12 AM
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 .........
0
Dobry Zranchev
Telerik team
answered on 02 Mar 2011, 02:43 PM
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!
Tags
Scheduler and Reminder
Asked by
santosh
Top achievements
Rank 1
Answers by
Jordan
Telerik team
shinu rag
Top achievements
Rank 1
Dobry Zranchev
Telerik team
Share this question
or